Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Dnyaneshwar_21
New Member

Connect SQL Server to Power BI Using Custom Scripts

Dnyaneshwar_21_0-1666264817314.png

I am trying to connect SQL Server to Power BI Using Custom Scripts,During this facing issue.
Regarding please check below Details - 
Python Script - 

import pandas as pd   

import pyodbc

conn = pyodbc.connect('Driver={SQL Server};'

                     'Server= ServerName ;' - Mentioned Correctly

                     'Database=Test;' - Mentioned Correctly

                     'Trusted_Connection=yes;')

cur= conn.cursor()

sqlquery = pd.read_sql_query('SELECT * FROM Customers',conn) - Mentioned Correctly

print(sqlquery)

Note - I have already Installed libaries which are needed.

pip install pyodbc

pip install pandas

pip install matplotlib



1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Dnyaneshwar_21 ,

You can refer to the following official Microsoft link for a detailed description of the error and the solution, as the situation is caused by your specific situation, and you can follow the steps in the link to troubleshoot it,refer:

https://learn.microsoft.com/en-us/troubleshoot/sql/connect/network-related-or-instance-specific-erro... 

vluwangmsft_0-1666333563737.png

 

Best Regards

Lucien

 

 

View solution in original post

1 REPLY 1
v-luwang-msft
Community Support
Community Support

Hi @Dnyaneshwar_21 ,

You can refer to the following official Microsoft link for a detailed description of the error and the solution, as the situation is caused by your specific situation, and you can follow the steps in the link to troubleshoot it,refer:

https://learn.microsoft.com/en-us/troubleshoot/sql/connect/network-related-or-instance-specific-erro... 

vluwangmsft_0-1666333563737.png

 

Best Regards

Lucien

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors