I am trying to connect to an existing PostgreSQL database. I am able to connect using the psql
command-line interface, as well as pgAdmin. However, when I try to connect a python environment (JupyterLab and DataSpell), I am unable to connect.
Version Information:
- psycopg2 version: 2.9.3
- sqlalchemy version: 2.0.2
- ipython-sql version: 0.3.9
- postgres version: 15.3
%load_ext sql
%env DATABASE_URL=postgresql://retail_user:retail@localhost/retail_db
%%sql
SELECT * FROM orders LIMIT 10
The above code outputs:
__init__() got an unexpected keyword argument 'bind' Connection info needed in SQLAlchemy format, example: postgresql://username:password@hostname/dbname or an existing connection: dict_keys([])
After some investigation, I discovered that downgrading SQLAlchemy to version 1.4.22 resolved this issue.