开发者

pymongo (python+mongodb) drop collection/gridfs?

开发者 https://www.devze.com 2023-01-19 03:06 出处:网络
Anyone know the commands to d开发者_如何学编程rop a collection of documents and also drop a gridfs database?To delete a collection, you can either call the drop() method on it, or use the drop_collect

Anyone know the commands to d开发者_如何学编程rop a collection of documents and also drop a gridfs database?


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')
0

精彩评论

暂无评论...
验证码 换一张
取 消