I want to put a mongodb database on local windowsarticles
Copy to server, server ip assumes 192.168.3.10.
I want to use mongodb’s python driver to write a python script:
transfer_mongodb.py
from pymongo import MongoClient
# Copy Database from windows to Server
def local_to_server():
client = MongoClient('localhost', 27017)
db = client.articles
# How should it be written here?
if __name__ == "__main__":
local_to_server()
What should we do?
There is no need to call it directly by script.
mongodump
+mongorestore
Don’t just get things done? Why write a python program?