我是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