-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SqlMagic.autocommit=True is not applied to connection options #90
Comments
was this executed in a new session? The error suggests that the |
@edublancas it happens when executing the session here. According to docs, setting the I didn't reference the original issue since I'm not sure we want to support this feature and if |
I looked at the code to understand why this is happening. It turns out, ipython-sql isn't using the psycopg2's autocommit feature. CREATE DATABASE my_test_db is the same as running this: BEGIN; -- executed since psycopg2's autocommit is off
CREATE DATABASE my_test_db; -- executed by the user
COMMIT; -- executed by ipython-sql due to the autocommit=True Which causes the error:
Psycopg2 issues the initial It's best to rely on the driver's autocommit feature rather than manually issuing a COMMIT command. However, since this is driver-dependent, we should only do it selectively. Perhaps something like this: if config.autocommit:
try:
conn.session.execution_options(isolation_level="AUTOCOMMIT")
except Exception as e:
# show some warning
# commit manually
manual_commit = True
else:
manual_commit = False Then, use the |
since we closed #117, now we can test this. the first thing is to check what happens when running:
we already know that postgres fails, but we'll see what happens with the others. then, we must check what happens with @yafimvo's solution: #91 my guess is that the final solution will involve some checking logic as I described in my earlier comment. since you worked on the integration tests, do you want to take this @tonykploomber ? |
I can take this |
FYI @jameshowison , this will be on the next release! |
Running
returns the following error:
The text was updated successfully, but these errors were encountered: