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

Problems with closed notebook connections

Open psychemedia opened this issue 7 years ago • 0 comments

I have a use case in which it is sometimes necessary to clear all the connections on a database when working in a notebook with %sql magic configured.

If I then try to create a new connection for the magic, I get an error:

Exception during reset or similar
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/pool.py", line 709, in _finalize_fairy
    fairy._reset(pool)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/pool.py", line 880, in _reset
    pool._dialect.do_rollback(self)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/default.py", line 457, in do_rollback
    dbapi_connection.rollback()
psycopg2.OperationalError: terminating connection due to administrator command
server closed the connection unexpectedly
	This probably means the server terminated abnormally
	before or while processing the request.

presumably because the magic is trying to use stale connection details?

One workaround for me would be to run a command to clear an outstanding connection details the sql magic thinks is set. But as per https://github.com/catherinedevlin/ipython-sql/issues/65 I don't think there's an obvious way of doing that?

psychemedia avatar May 23 '18 12:05 psychemedia