I tried several times to connect to Azure SQL Database.
I used the following code:
import pyodbc
sqlConnection = pyodbc.connect(
" Driver={ODBC Driver 17 for SQL Server};"
"Server=tcp:mftaccountinghost.database.windows.net,1433;"
"Database=mft_accounting;Uid=localhost;Pwd=#####;"
"Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;");
cursor = sqlConnection.cursor()
cursor.execute("select * from dbo.error_bills_catch")
for row in cursor:
print(cursor)
firstColumn = row[0]
cursor.close()
sqlConnection.close()
The error I get is following:pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection (0) (SQLDriverConnect)')
Can anyone maybe help?
This is my connection string: Driver={ODBC Driver 13 for SQL Server};Server=tcp:mftaccountinghost.database.windows.net,1433;Database=mft_accounting;Uid=localhost;Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
I use MacOs and tried several time to reinstall the driver, but still without result.
Thank you.