Skip to content

IPython - AttributeError: 'Connection' object has no attribute '_pgcli' #1520

@klonuo

Description

@klonuo

Latest packages, up to date:

In [3]: %pgcli postgresql://localhost/meaurements
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File ~/.local/lib/python3.12/site-packages/pgcli/magic.py:36, in pgcli_line_magic(line)
     34 try:
     35     # A corresponding pgcli object already exists
---> 36     pgcli = conn._pgcli
     37     _logger.debug("Reusing existing pgcli")

AttributeError: 'Connection' object has no attribute '_pgcli'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 get_ipython().run_line_magic('pgcli', 'postgresql://localhost/meaurements')

File ~/.local/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2504, in InteractiveShell.run_line_magic(self, magic_name, line, _stack_depth)
   2502     kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2503 with self.builtin_trap:
-> 2504     result = fn(*args, **kwargs)
   2506 # The code below prevents the output from being displayed
   2507 # when using magics with decorator @output_can_be_silenced
   2508 # when the last Python token in the expression is a ';'.
   2509 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File ~/.local/lib/python3.12/site-packages/pgcli/magic.py:43, in pgcli_line_magic(line)
     38 except AttributeError:
     39     # I can't figure out how to get the underylying psycopg2 connection
     40     # from the sqlalchemy connection, so just grab the url and make a
     41     # new connection
     42     pgcli = PGCli()
---> 43     u = conn.session.engine.url
     44     _logger.debug("New pgcli: %r", str(u))
     46     pgcli.connect_uri(str(u._replace(drivername="postgres")))

AttributeError: 'Connection' object has no attribute 'session'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions