I'm trying to save a dataframe to MS SQL that uses Windows authentication. I've tried using engine
, engine.connect()
, engine.raw_connection()
and they all throw up errors:
'Engine' object has no attribute 'cursor'
, 'Connection' object has no attribute 'cursor'
, and Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;': ...
respectively.
params = urllib.parse.quote('DRIVER={ODBC Driver 13 for SQL Server};'
'SERVER=server;'
'DATABASE=db;'
'TRUSTED_CONNECTION=Yes;')
engine = create_engine('mssql+pyodbc:///?odbc_connect=%s' % params)
df.to_sql(table_name,engine, index=False)