PyMongo
Manipulate Database/Collection
Database List
client.list_database_names()Use a Database
db = client.test_database
# or
db = client['test_database']Collection list
db.list_collection_names()Use a Collection
collection = db['test_collection']
# or
collection = db.test_collectionCreate a collection
db.create_collection(‘test_collection’)Drop a collection
db.test_collection.drop()
# or
db.drop_collection('test_collection’)Drop a database
Dictionary
Using dictionaries to represent documents
Last updated
Was this helpful?