Skip to content

Instantly share code, notes, and snippets.

@jmquintana79
Last active July 19, 2021 07:57
Show Gist options
  • Save jmquintana79/30462b0f2b60107742c394fa116fbd41 to your computer and use it in GitHub Desktop.
Save jmquintana79/30462b0f2b60107742c394fa116fbd41 to your computer and use it in GitHub Desktop.
Store Pandas dataframe content into MongoDb
from pymongo import MongoClient
from odo import odo
import pandas as pd
# open connection
connection = MongoClient()
# pandas df creation
DF = pd.DataFrame({'A': [1,2,3,4,5,6,7], 'B':[10,20,30,40,50,60,70]})
# database connection
db = connection.<database>
# insert df into mongo <table>
odo(DF, db.<table>)
@jmquintana79
Copy link
Author

So simple. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment