I can connect to the sql-server database and read data from python using,
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=server_name;DATABASE=testdb;UID=Another_Domain\\username;PWD=pass; Trusted connection=YES')
But when I try to write data from python to sql-server using,
engine = create_engine('mssql+pyodbc://user:password@host:port/myDB')
conn = engine.connect()
I get an error,
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)
How can I connect?
sqlalchemy, and its connection syntax is very different from pyodbc. You have to assign the driver string explicitly. You may refer to the following MWE (minimum working example) and see if it works. stackoverflow.com/a/60636359/3218693