Skip to content

Instantly share code, notes, and snippets.

@gccpacman
Created April 28, 2016 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gccpacman/fa338c9941d5bc182d88595a58351a93 to your computer and use it in GitHub Desktop.
Save gccpacman/fa338c9941d5bc182d88595a58351a93 to your computer and use it in GitHub Desktop.
test mongo db connect
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
@gccpacman
Copy link
Author

could be use to test if mongo db could be connect or not successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment