How do I give my local computer access to my SQL database in Azure? I am trying to run code that needs to access my Azure database, but I get the following error:
I already tried adding my IP address to the firewall rules. What else can I do?
How do I give my local computer access to my SQL database in Azure? I am trying to run code that needs to access my Azure database, but I get the following error:
I already tried adding my IP address to the firewall rules. What else can I do?
You need to define the full connection string in you Python code.
For example, in case you are using a username/password instead of a trusted connection, here’s a relevant example:
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=server_name;DATABASE=database_name;UID=user;PWD=password')
In case you are using a trusted connection, here’s another relevant example:
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=server_name;DATABASE=database_name;Trusted_Connection=yes;')
For more troubleshooting approach, you can refer this third-party article.