You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I looked at the code to understand why this is failing.
It turns out, ipython-sql isn't using the psycopg2's autocommit feature. %config SqlMagic.autocommit=True sets a flag that causes ipython-sql to run COMMIT after each command; so, if we turn it on, running this:
CREATEDATABASEmy_test_db
is the same as running this:
BEGIN; -- executed since psycopg2's autocommit is offCREATEDATABASEmy_test_db; -- executed by the userCOMMIT; -- executed by ipython-sql due to the autocommit=True
Which causes the error:
CREATE DATABASE cannot run inside a transaction block
@jameshowison my team maintains a fork of this project and we're tackling this issue already so feel free to share your feedback! ploomber#90
pmfischer
pushed a commit
to pmfischer/ipython-sql
that referenced
this issue
Sep 8, 2023
Using ipython-sql 0.3.9 installed via conda together with postgres and I'm not sure if the SqlMagic.autocommit=True option is working.
This code
Produces a
InternalError: (psycopg2.errors.ActiveSqlTransaction) CREATE DATABASE cannot run inside a transaction block
error.Conversely, this works fine
Anyone know if
%config SqlMagic.autocommit=True
is supposed to do the same asconn.autocommit = True
The text was updated successfully, but these errors were encountered: