What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-21 18:31:14
how to bulk update in mongodb using python
import pymongo conn = pymongo.MongoClient('myserver', 8839) db = conn['mydbname'] coll = db.myCollection bulkop = coll.initialize_ordered_bulk_op() retval = bulkop.find({'field1':1}).upsert().update({'$push':{'vals':1}}) retval = bulkop.find({'field1':1})... Add solution -
Other 2021-11-19 05:52:24
Traceback (most recent call last): File "app.py", line 2, in <module> import pymongo ModuleNotFoundError: No module named 'pymongo'
Traceback (most recent call last): File "app.py", line 2, in <module> import pymongo ModuleNotFoundError: No module named 'pymongo' Add solution -
Python 2021-11-17 12:34:27
python import json into pymongo
import json from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client['countries_db'] collection_currency = db['currency'] with open('currencies.json') as f: file_data = json.load(f) # if pymongo < 3.0, use insert() co... Add solution -
Python 2021-11-06 08:26:14
python mongodump
from os.path import join import pymongo from bson.json_util import dumps def backup_db(backup_db_dir): client = pymongo.MongoClient(host=..., port=..., username=..., password=...) database = client[<db_name>] collections = database.coll... Add solution -
Javascript 2021-10-05 22:00:04
pymongo add json to collection
client = MongoClient('localhost', 27017) db = client['countries_db'] collection_currency = db['currency'] with open('currencies.json') as f: file_data = json.load(f) collection_currency.insert(file_data) # pymongo < 3.0 collection_currency.insert... Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5