Hi all! So I am having problems connecting to my Azure SQL database. I am trying to do this with python by following the instructions here:
https://learn.microsoft.com/en-us/sql/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc?view=sql-server-ver15
My code:
The results when run:
I have installed pyodbc and confirmed that I have ODBC driver 17 installed:
I performed a trace on the azure server, which seems to suggest that the company firewall is not an issue (though would seek advice on this):
Tried pretty much every suggestion here:
https://stackoverflow.com/questions/18860620/cannot-establish-connection-to-sql-server-using-pyodbc-on-windows-7
Including defining the connection string parameters as keyword arguments:
cnxn = pyodbc.connect(driver='{ODBC Driver 17 for SQL Server}', SERVER=server, DATABASE=database, UID=username, PWD=password)
I have set the public access firewall settings for the database within the Azure Hub following the instructions here: IP firewall rules - Azure SQL Database and Azure Synapse Analytics | Microsoft Learn
My settings:
I then tried to connect to the database with Visual Studio Code from with the Azure Hub:
However, I had similar luck:
Could anyone offer me any advice on what the problem may be and how I can overcome this to connect to my Azure SQL database?
Thanks in advance!