Forum Discussion
Notebook connect to Fabric SQL Database
- 1 year ago
Hi MangoMagic ,
The error you're seeing is a login timeout from the ODBC Driver 18 for SQL Server when trying to connect to a Fabric SQL database via pyodbc, and it’s usually due to unreachable server endpoints, blocked ports, or mismatched authentication settings. First, I checked if the server address was reachable by pinging it and testing port 1433 to rule out network issues. Then, since ActiveDirectoryIntegrated is known to fail if the machine isn’t domain-joined or lacks token access, I swapped it with ActiveDirectoryInteractive in the connection string to trigger a proper login prompt. I also added a longer timeout value, like Timeout=60, to give the connection more breathing room. On top of that, I made sure the firewall or VPN wasn’t blocking outbound traffic, and tried a quick login via SSMS or Azure Data Studio just to confirm the database was accessible outside the script. These steps helped narrow down where the failure point was and ensured a smoother connection setup.
Best Regards,
Lakshmi Narayana
MangoMagic Hi, there is a standardized way of connecting a notebook with a Fabric SQL server. This is how it works:
1. Create a Lakehouse that will be used with a notebook.
2. In the Lakehouse create a shortcut to a Fabric SQL database choosing an internal OneLake data source and selecting required tables in the Fabrci SQL database.
3. Notice that the shortcut is created in the Lakehouse's Files section in a Folder that corresponds to a shortcut name. All database tables will be present there as delta tables in corresponding subfolders. Using the (...) menu find a "Name for Spark" for a necessary table.
4. Open a notebook and in a PySpark code cell load data from the delta table into a dataframe using delta format and the Table path in the shortcut.
Now you have connected your notebook to the Fabric SQL database. Keep in mind, that you can only read data from the database using a notebook and a shortcut, but cannot write to or modify the database schema.
Hope this helps.
You can find more information in this post Re: Querying a Fabric SQL Database from a Notebook - Microsoft Fabric Community
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.