-1

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:

enter image description here

I already tried adding my IP address to the firewall rules. What else can I do?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Please do not paste the screenshot of the error message. Share the actual error message (with stack trace if possible) as text. – Gaurav Mantri Jun 16 '22 at 15:27
  • You also need to show us the code that is giving you the error. – Dour High Arch Jun 16 '22 at 17:11
  • Sharing some links with similar error and suggested solutions. Please refer and do let me know if this helps you. And also share some code part what you have tried. https://stackoverflow.com/questions/46045834/pyodbc-data-source-name-not-found-and-no-default-driver-specified, https://www.sqlnethub.com/blog/how-to-resolve-im002-microsoftodbc-driver-manager-data-source-name-not-found-and-no-default-driver-specified-0-sqldriverconnect/ – Utkarsh Pal Jun 17 '22 at 02:05

1 Answers1

1

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.

Utkarsh Pal
  • 4,079
  • 1
  • 5
  • 14