12-21-2022, 04:57 AM
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()
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()