Forum Discussion
How to Connect to Power BI Service Datasets and Pull Data Using Python Locally (Outside Fabric)
- 1 year ago
import adodbapi # Connection string (edit table and workspace as needed) conn = adodbapi.connect("Provider=MSOLAP.8; \ Data Source='powerbi://api.powerbi.com/v1.0/myorg/Testws'; \ Initial Catalog='db1'") # Create cursor cursor = conn.cursor() # Replace 'YourTableName' with a real table name in your data model dax_query = "EVALUATE 'table'" print("Querying table: table") cursor.execute(dax_query) # Fetch column names columns = [column[0] for column in cursor.description] print("Columns:", columns) # Fetch all rows rows = cursor.fetchall() for row in rows: print(row) # Close the connection cursor.close() conn.close()This approach is working for me
You can mark this as a solution
Thanks
Hi AkhilGrandhi1,
Since we haven't heard back from you yet, I'd like to confirm if you've successfully resolved this issue or if you need further help?
If you've already resolved the issue, you can mark the helpful reply as a "solution" so others know that the question has been answered and help other people in the community. Thank you again for your cooperation!
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
import adodbapi
# Connection string (edit table and workspace as needed)
conn = adodbapi.connect("Provider=MSOLAP.8; \
Data Source='powerbi://api.powerbi.com/v1.0/myorg/Testws'; \
Initial Catalog='db1'")
# Create cursor
cursor = conn.cursor()
# Replace 'YourTableName' with a real table name in your data model
dax_query = "EVALUATE 'table'"
print("Querying table: table")
cursor.execute(dax_query)
# Fetch column names
columns = [column[0] for column in cursor.description]
print("Columns:", columns)
# Fetch all rows
rows = cursor.fetchall()
for row in rows:
print(row)
# Close the connection
cursor.close()
conn.close() This approach is working for me
You can mark this as a solution
Thanks
- v-sgandrathi1 year agoCommunity Support
HI AkhilGrandhi1,
I'm glad you found a solution and resloved the query. Thank you very much for sharing here.
Kindly mark your reply as the accepted solution so that others in the community can find it quickly.
Thankyou for connecting with Microsoft Community Forum.