Skip to content

Instantly share code, notes, and snippets.

View prakashthegyan's full-sized avatar

Gyan Prakash Tripathi prakashthegyan

View GitHub Profile
post = {"_id": 'qwertyui123456',
'username': 'someone',
'name':'Gyan',
'address':'Somewhere in India'}
post_id = table.insert_one(post).inserted_id
post_id
table.find().sort("_id",pymongo.DESCENDING)
first_instance['name']
first_instance.keys()
table.find_one()
table=db.customers
table.count_documents({}) #gives the number of documents in the table
db.list_collection_names()
db = client.sample_analytics
client.list_database_names()
import pymongo
import pprint
mongo_uri = "mongodb://localhost:27017/"
client = pymongo.MongoClient(mongo_uri)