ipython-sql
ipython-sql copied to clipboard
Syntax error: COMMIT WORK not allowed for a DBC/SQL session
Hey,
I have the following setup: Jupyter+SqlAlchemy+SqlAlchemy-teradata+ipython-sql.
Every select statement I tried will raise the following exception: DatabaseError: (DatabaseError) (3706, '[42000] [Teradata][ODBC Teradata Driver][Teradata Database] Syntax error: COMMIT WORK not allowed for a DBC/SQL session. ') 'commit' ()
As a quick fix, I commented the conn.session.execute('commit') in the run() function. Any other ideas ?
This causes problems also for other engines. Probably should be handled differently.
Fixed the issue.
Turned off auto commit for Teradata dialect on line https://github.com/catherinedevlin/ipython-sql/blob/master/src/sql/run.py#L279.
Just replace below code
# mssql has autocommit
if 'mssql' not in str(conn.dialect):
conn.session.execute('commit')
by
# mssql has autocommit
if ('mssql' not in str(conn.dialect) and 'teradata' not in str(conn.dialect)):
conn.session.execute('commit')
Now, I'm able to run teradata sqls without any issue.