You can delete a table, or collection as it is called in MongoDB, by using the drop()
method.
Delete the "customers" collection:
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["customers"]
mycol.drop()
Run example »
The drop()
method returns true if the collection was dropped successfully, and false if the collection does not exist.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!