Write data to a MongoDB collection using python - Printable Version +- Forums (https://bdn.bdb.ai) +-- Forum: BDB Knowledge Base (https://bdn.bdb.ai/forumdisplay.php?fid=13) +--- Forum: BDB Data Pipeline (https://bdn.bdb.ai/forumdisplay.php?fid=48) +---- Forum: BDB Data Pipeline Q & A (https://bdn.bdb.ai/forumdisplay.php?fid=17) +---- Thread: Write data to a MongoDB collection using python (/showthread.php?tid=347) |
Write data to a MongoDB collection using python - shreekantgosavi - 12-21-2022 Use python script component. Paste below script in meta information script section. import pandas as pd from pymongo import MongoClient def myconnect(data): df = data client = MongoClient("mongodb://localhost:27017/") #connection_string mydatabase = client.db_name #dbname mycollection = mydatabase.collection_name #collection_name mycollection.insert_many(df.to_dict('records')) client.close() |