Forum Discussion
Sql database in Fabric
- 1 year ago
Thank you for the response.
I followed all the suggested steps:
- Confirmed DNS and network connectivity (nslookup, Test-NetConnection).
- Verified I have ODBC Driver 18 and pyodbc installed.
- Ran my Python script with ActiveDirectoryInteractive and also tried other auth methods.
- Checked my Azure tenant and found I have no valid subscription assigned or active.
It turns out my subscription status is causing the issue. I don’t have any active Azure subscription in my tenant.
Hello!
I think I am having a similar issue.
I am trying to connect to a Fabric SQL Database from a Flask/Python web app and am hitting an error like this
sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('FA004', "[FA004] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Failed to authenticate the user '[email protected]' in Entra ID (Authentication option is 'ActiveDirectoryInteractive').\r\nError code 0x534; state 11\r\n(null) (0) (SQLDriverConnect); [FA004] [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Failed to authenticate the user '[email protected]' in Entra ID (Authentication option is 'ActiveDirectoryInteractive').\r\nError code 0x534; state 11\r\n(null) (0)")
(Background on this error at: https://sqlalche.me/e/20/dbapi)
I have now downloaded the ODBC Driver 18 to try to test the connection using that, but I can't get that to work either.
I am a database owner, a Capacity admin and an admin of the workspace too.
Would you be able to give a check list of things to test?
Many thanks
Oliver
- dlevy1 year agoMicrosoft Employee
Hi OliverO - Here is an example using pyodbc but the connection string is the same for sqlalchemy.
""" Connects to a SQL database using pyodbc """ import pyodbc connectionString = f'DRIVER={{ODBC Driver 18 for SQL Server}};Server=tcp:<redacted>.database.windows.net,1433;Database=<redacted>;Encrypt=yes;TrustServerCertificate=no;Authentication=ActiveDirectoryInteractive' conn = pyodbc.connect(connectionString) SQL_QUERY = """ SELECT TOP 5 c.CustomerID, c.CompanyName, COUNT(soh.SalesOrderID) AS OrderCount FROM SalesLT.Customer AS c LEFT OUTER JOIN SalesLT.SalesOrderHeader AS soh ON c.CustomerID = soh.CustomerID GROUP BY c.CustomerID, c.CompanyName ORDER BY OrderCount DESC; """ cursor = conn.cursor() cursor.execute(SQL_QUERY) records = cursor.fetchall() for r in records: print(f"{r.CustomerID}\t{r.OrderCount}\t{r.CompanyName}")This works with the AdventureWorks sample data. Make sure to include the entire server and database names, including GUIDs.
- OliverO1 year agoHelper III
Thanks Mr Levy! I will try this tomorrow