Connection string using odbc driver

from sqlalchemy import create_engine
import pyodbc

AZUREUID = ‘######’ # Azure SQL database userid
AZUREPWD = ‘######’ # Azure SQL database password
AZURESRV = ‘#######’ # Azure SQL database server name (fully qualified)
AZUREDB = ‘####’ # Azure SQL database name (if it does not exit, pandas will create it)
DRIVER = ‘{ODBC Driver 17 for SQL Server}’
connectionstring = ‘mssql+pyodbc://{uid}:{password}@{server}:1433/{database}?driver={driver}’.format(
uid=AZUREUID,
password=AZUREPWD,
server=AZURESRV,
database=AZUREDB,
driver=DRIVER.replace(’ ', ‘+’))
engine = create_engine(connectionstring)

when i try to run the code above, it gives error DBAPIError: (pyodbc.Error) (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘{ODBC Driver 17 for SQL Server};Server=#####,1433;Database=###;UID=####;PWD=###’ : file not found (0) (SQLDriverConnect)”) (Background on this error at: http://sqlalche.me/e/dbapi

What could be the solution to this because I couldn’t find it even after googling for hours.

Hello.

I’m not familiar with odbc, but it seems that installing pyodbc doesn’t install any drivers. At least, executing pyodbc.dirvers() returns empty list. So you probably need to install/download driver manually. Then explicitly setting DRIVER = "/path/to/driver" instead of using implicit {ODBC Driver 17 for SQL Server} may help.