Guest User

Untitled

a guest
Jul 31st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. def write_data(documents, collection_name):
  2. # when running locally
  3. #client = pymongo.MongoClient("localhost", 3001)
  4. #db = client.meteor
  5.  
  6. # on the server
  7. client = MongoClient(mongoURL, username=****,
  8. password=****)
  9. db = client.mercurius
  10.  
  11. if collection_name in db.collection_names():
  12. collection = db[collection_name]
  13. collection.drop()
  14.  
  15. new_collection = db[collection_name]
  16. new_collection.insert_many(documents)
  17.  
  18. cursor = new_collection.find({})
  19. for document in cursor:
  20. print(document)
  21.  
  22. Meteor.call( 'getDBinfo', function(err, response){
  23. console.log(response);
  24. console.log(err);
  25. });
Add Comment
Please, Sign In to add comment