Open tonykploomber opened 1 year ago
Seems the error is thrown from psycopg package, but I am think the issue is calling from log.debug(formatted_query.as_string(cur))
in dbcommands.py
It seems that you are passing a psycopg 2 connection where a psycopg 3 one is expected. Maybe you upgraded the package, but not the dependencies.
I cannot reproduce this issue with recent versions of everything:
$ pip install sqlalchemy pgspecial
[...]
Successfully installed [...] pgspecial-2.1.1 psycopg-3.1.18 sqlalchemy-2.0.30 [...]
Then, in a Python shell:
>>> from sqlalchemy import create_engine
>>> from pgspecial.main import PGSpecial
>>> eng = create_engine("postgresql+psycopg://pgcli-dev:pgcli-dev@localhost/pgcli-dev").connect()
>>> pgspecial = PGSpecial()
>>> pgspecial.execute(eng.connection.cursor(), "\d")
[(None, <psycopg.Cursor [TUPLES_OK] [INTRANS] (host=localhost database=pgcli-dev) at 0x7f440080e770>, ['Schema', 'Name', 'Type', 'Owner'], 'SELECT 7')]
Note that the connection string must start with postgresql+psycopg://
and not just postgresql://
for SQLAlchemy to use psycopg3 (see SQLAlchemy docs here).
Hello, I noticed one issue after upgrading pgspecial to 2.1.0.
The issue is I used sqlalchemy to construct my connection,
Following code works fine in pgspecial.2.0.1, but not 2.1.0 version
Way to reproduce the issue:
Trace
Versions: Python 3.9 sqlalchemy-2.0.8