Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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()
Comment

PREVIOUS NEXT
Code Example
Python :: plotly plot size 
Python :: python querystring parse 
Python :: dictionaries to http data python 
Python :: how to apply logarithm in pandas dataframe 
Python :: extract frames from video python 
Python :: get xpath of element selenium python 
Python :: python sort list of strings numerically 
Python :: name exit not defined python 
Python :: How to use tqdm with pandas apply 
Python :: brownie to wei 
Python :: AssertionError: Relational field must provide a `queryset` argument, override `get_queryset`, or set read_only=`True` 
Python :: como eliminar palabras repetidos de una lista python 
Python :: python format currency 
Python :: pandas multiple string contains 
Python :: install gtts 
Python :: python randomized selection 
Python :: python datetime strptime hour minute second 
Python :: discord.py change status 
Python :: pyspark session 
Python :: pandas index to list 
Python :: last element in dictionary python 
Python :: python cube turtle 
Python :: heroku change python version 
Python :: django rest framework configuration 
Python :: pandas to csv encoding 
Python :: how to use python to print multiplication table 
Python :: python print to terminal with color 
Python :: pandas date_range 
Python :: flipping an image with cv2 
Python :: djangodebug toolbar not showing 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =