我是mongoDB和pymongo的新手,试图学习如何从/向磁盘加载和保存数据库,以便我可以随身携带并将它发送给人员等。我已阅读http://api.mongodb.org/python/current/tutorial.html的教程,但找不到有关保存和加载数据库的有用信息。使用pymongo加载和保存mongoDB数据库从/到磁盘
假设我们创建这样一个数据库:
import pymongo
mongo = pymongo.Connection()
db = mongo['my_db']
col = db['my_col']
col.insert({'name': 'Adam','occupation': 'student'})
col.insert({'name': 'John','occupation': 'officer'})
#how can we save the database to disk after this point
#and later read it from another program?
读这首先http://api.mongodb.org/ python/current/tutorial.html –
事实上,我确实没有保存和加载db的信息。 – MHardy
我不明白你在问什么。 'insert'将数据保存到数据库。如果您将“从/到磁盘”加载到哪里,您希望它加载到哪里?我想你可能需要在这里了解数据库的基础知识。 – Sammaye