Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I am trying to access the sql database inside the fabric using notebook with connection string but i am getting error
('HYT00', '[HYT00] [Microsoft][ODBC Driver 18 for SQL Server]Login timeout expired (0) (SQLDriverConnect)')
thanks for reply i am able to reslove my error by changing authentication in my code to
Have you seen this example? Access OneLake with Python - Microsoft Fabric | Microsoft Learn
The other angle would be to go through the SQL Analytics Endpoint. That will work just like a read-only SQL server so you should already have most of the code for that.
Otherwise, you may want to ask in the Lakehouse area.
Hi @munindra - Here is an example that one of our private preview customers got working in their notebooks:
def run_select_query(query_text):
# Define JDBC URL and connection properties
jdbc_url = "jdbc:sqlserver://<server>;" \
"database=<db>;" \
"encrypt=true;trustServerCertificate=false;authentication=ActiveDirectoryServicePrincipal;"
connection_properties = {
"user": f"{client_id}@{tenant_id}",
"password": client_secret,
"driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver"
}
# Define your SQL query
query = query_text
# Read data from Azure SQL Database using the query
df = spark.read \
.format("jdbc") \
.option("url", jdbc_url) \
.option("dbtable", query) \
.option("user", connection_properties["user"]) \
.option("password", connection_properties["password"]) \
.option("driver", connection_properties["driver"]) \
.load()
# Show the data
# df.show()
return dfPlease feel free to make it your own, including making sure it is safe to run in your environment.
The big thing you'll notice is that this requires an Entra Service Principal. That is the only option that will work right now.
Hi @munindra
You can refer to the following link to make sure that your format is right.
SQL connection with Python - Microsoft Fabric Community
And please make sure that your server name and the username and the password is right, you can refer to the following link about the connection of database.
Connect to your SQL database - Microsoft Fabric | Microsoft Learn
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Fabric update to learn about new features.