Reputation: 117
I am trying to use python's sqlalchemy library for connecting to microsoft azure data warehouse. and receiving the following error:
[ODBC Driver 17 for SQL Server][SQL Server]111214;An attempt to complete a transaction has failed. No corresponding transaction found. (111214)
The current code that I have tried:
import sqlalchemy
import urllib
params = urllib.quote_plus("Driver={ODBC Driver 17 for SQL Server};Server=<server-host>.database.windows.net,1433;Database=<database>;Uid=<user>@<server-host>;Pwd=<password>;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;")
engine = sqlalchemy.engine.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)
engine.connect()
I can't seem to understand where the error is...is it db side or is my ODBC connection not right? I pulled it out of the Azure portal so I doubt that could be the case.
Upvotes: 3
Views: 1131
Reputation: 117
Ended up using this for the engine instead. Had to add connect_args.
engine = create_engine('mssql+pyodbc:///?odbc_connect=%s' % params, echo=True, connect_args={'autocommit': True})
Upvotes: 6