I am trying to connect to a SQL Server database using SQLAlchemy on a Databricks cluster.
I have some simple code that looks like this,
db_conn_str = "mssql+pyodbc://<user-name>:<password>@<server-name>.database.windows.net:1433/<database-name>?driver=SQL Server"
engine = sa.create_engine(db_conn_str)
metadata = sa.MetaData(bind=None)
table = sa.Table(
table_name,
metadata,
autoload=True,
autoload_with=engine,
schema=TABLE_SCHEMA
)
Note: This code is actually written within a custom Python Package that I am calling from Databricks.
However, I keep getting the following error,
DBAPIError: (pyodbc.Error) ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'SQL Server' : file not found (0) (SQLDriverConnect)")
What exactly is going on here and how can I resolve this?
Another fact that I think should be mentioned is that usually when connecting to my SQL Server database, I need to whitelist my IP. However, I am not sure how this applies when connecting using Databricks.