Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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_one(file_data) # pymongo >= 3.0
collection_currency.insert_many(file_data) # pymongo >= 3.0

client.close()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pymongo #add #json #collection
ADD COMMENT
Topic
Name
2+8 =