Forum Discussion
sharath123
4 years agoHelper I
MongoDB Data is not showing in powerbi by using python script
import pymongo from pymongo import MongoClient connection = pymongo.MongoClient("mongodb+srv://<username>:<password>@cluster0.zev7c.mongodb.net/myFirstDatabase?retryWrites=true&w=majority") db=c...
- 3 years ago
This seemed to work:
# Specify the collection name
collection = db['your_collection_name']
# Perform the query
query = {} # Your query conditions here
result = collection.find(query)
# Convert the query result to a DataFrame
df = pd.DataFrame(result)
# Print the DataFrame
print(df)
sharath123
4 years agoHelper I
TomMartens thanks. but how to convert this result into a data frame?
please provide the syntax to convert the result into a data frame, so that I run the script in powerbi.
loch45
3 years agoNew Member
This seemed to work:
# Specify the collection name
collection = db['your_collection_name']
# Perform the query
query = {} # Your query conditions here
result = collection.find(query)
# Convert the query result to a DataFrame
df = pd.DataFrame(result)
# Print the DataFrame
print(df)