Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write data to a MongoDB collection using python
#1
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()
Reply


Messages In This Thread
Write data to a MongoDB collection using python - by shreekantgosavi - 12-21-2022, 05:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)