Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to read a MongoDB collection using python in pipeline?
#1
Use python script component.
Under meta information paste below script in script section.
Provide required credentials.
import pandas as pd
from pymongo import MongoClient
def myread():
    client = MongoClient("mongodb://localhost:27017/"#connection_string
    mydatabase = client.db_name#cdatabase_name
    mycollection = mydatabase.collection_name #collection_name
    cursor = mycollection.aggregate([ { '$project': { '_id': 0}}]) #aggregate_query
    df = pd.DataFrame(list(cursor))
    client.close()
    return df
myread()
Reply


Messages In This Thread
How to read a MongoDB collection using python in pipeline? - by shreekantgosavi - 12-21-2022, 04:57 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)