Horje
python import json into pymongo Code Example
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()
collection_currency.insert(file_data)
# if pymongo >= 3.0 use insert_one() for inserting one document
collection_currency.insert_one(file_data)
# if pymongo >= 3.0 use insert_many() for inserting many documents
collection_currency.insert_many(file_data)

client.close()




Python

Related
matplotlib legend out of plot Code Example matplotlib legend out of plot Code Example
les librairies python a maitriser pour faire du machine learning Code Example les librairies python a maitriser pour faire du machine learning Code Example
How to detect key presses Code Example How to detect key presses Code Example
reload all extensions discord.py Code Example reload all extensions discord.py Code Example
how to launch an application using python Code Example how to launch an application using python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7