ipython-sql icon indicating copy to clipboard operation
ipython-sql copied to clipboard

Syntax error: COMMIT WORK not allowed for a DBC/SQL session

Open essamsalah opened this issue 9 years ago • 2 comments

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 ?

essamsalah avatar May 11 '16 07:05 essamsalah

This causes problems also for other engines. Probably should be handled differently.

KarolTx avatar May 15 '16 09:05 KarolTx

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.

pkasinathan avatar Nov 12 '16 02:11 pkasinathan