Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pymongo (python+mongodb) drop collection/gridfs?

Anyone know the commands to drop a collection of documents and also drop a gridfs database?

like image 352
Joe Avatar asked Oct 09 '10 03:10

Joe


1 Answers

To delete a collection, you can either call the drop() method on it, or use the drop_collection() method on the database object:

my_collection = db['collection_name']
my_collection.drop()

# Or...

db.drop_collection('collection_name')

GridFS files are stored in a collection called fs by default. To delete the GridFS files, just drop that collection:

db.drop_collection('fs')
like image 88
Cameron Avatar answered Oct 26 '22 23:10

Cameron