The create_engine()
statement doesn't seem to work when using mssql+pyodbc
, it throws an InterfaceError
. The same happens when I try to use turbodbc
. However, it works fine when using mssql+pymssql
.
Mainly, I'm trying to speed up my df.to_sql()
operation. To that end, I tried two options.
- using pyodbc and implementing
fastexecutemany = True
. - using
turbodbc
.
Both options throw the same error when used in the create_engine()
command.
I am using Windows 10 and Windows Authentication, Python 3.7.
The connection can be established using pyodbc. So, this works:
cnxn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};"
"Server=server;"
"Database=database;"
"Trusted_Connection=yes;")
I CAN DO:
cnx = create_engine('mssql+pymssql://@server/database')
df.to_sql(name = name, con=cnx, if_exists = 'append', index=False)
I CANNOT DO:
cnx = create_engine('mssql+pyodbc://@server/database')
df.to_sql(name = name, con=cnx, if_exists = 'append', index=False)
I get the following error message:
InterfaceError: (pyodbc.InterfaceError) ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')(Background on this error at: http://sqlalche.me/e/rvf5)
Inerestingly, the same thing happens when I try
cnx = create_engine('mssql+turbodbc://@server/database')
Clearly, something in the way I set up my engine and try to connect to the database fails.