Created
June 13, 2018 01:19
-
-
Save dipakyadav/237b48cc64b3c5c68ece7f691bd5ab8c to your computer and use it in GitHub Desktop.
Try pymongo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from pymongo import MongoClient | |
>>> client = MongoClient("mongodb+srv://kay:[email protected]/test?retryWrites=true") | |
>>> db = client.test_database | |
>>> collection = db.test_collection | |
>>> import datetime | |
>>> post = {"author": "Mike", "text": "My first blog post!", "tags": ["mongodb", "python", "pymongo"], "date": datetime.datetime.utcnow()} | |
>>> posts = db.posts | |
>>> post_id = posts.insert_one(post).inserted_id | |
>>> post_id | |
ObjectId('5b2070f157a2f413b5d6c668') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment