I am new to databricks and I need to schedule some code that transforms and writes data to an azure sql database using python.
I get the following error: DBAPIError: (pyodbc.Error) ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
Running the code locally works fine and writes the data to the azure sql db.
Herebelow a sample of my code
server = "example.database.windows.net"
database = ""
username = ""
password = ""
driver = '{ODBC Driver 17 for SQL Server}'
odbc_str = 'DRIVER='+driver+';SERVER='+server+';PORT=1433;UID='+username+';DATABASE='+ database + ';PWD='+ password
connect_str = 'mssql+pyodbc:///?odbc_connect=' + urllib.parse.quote_plus(odbc_str)
engine = create_engine(connect_str)
df = pd.DataFrame({"Def": [1,2,3,4,5]})
def to_sql(df, table):
df.to_sql(table, engine, if_exists = "replace", index=False, chunksize = 100)
to_sql(df, "Def")
