Created
April 28, 2016 11:44
-
-
Save gccpacman/fa338c9941d5bc182d88595a58351a93 to your computer and use it in GitHub Desktop.
test mongo db connect
This file contains 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
import pymongo | |
import datetime | |
client = pymongo.MongoClient("mongodb://localhost/test") | |
db = client.test_database | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
could be use to test if mongo db could be connect or not successfully