0

I would like to drop all the files in GridFS but I didn't manage to do it :

from pymongo import MongoClient from bson.objectid import ObjectId #add the file to GridFS, per the pymongo documentation: http://api.mongodb.org/python/current/examples/gridfs.html db_file = MongoClient('192.168.0.16', 27017).db_file fs = gridfs.GridFS( db_file ) db_file.drop_collection('files') db_file.drop_collection('chunks') db_file.drop_collection('test') out = fs.get(ObjectId('57683734f525bc3d7420c262')) print(out) fp = open("test.mp3", 'wb') fp.write(out.read()) fp.close() 

At the end of the code i still have a file created and i can still play it.

1 Answer 1

1

Try this:

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

or drop database :

client = MongoClient('192.168.0.16', 27017)
client.drop_database("database_name")

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.