I am seeing a connection error when i try to read data from postgressql in my jupyter notebook. The error suggests:
Connection info needed in SQLAlchemy format, example:
postgresql://username:password@hostname/dbname
or an existing connection: dict_keys([])
As far as i can see the example format matches with my connection string provided.
I have also checked that i have updated version of sqlachemy.
What am i missing ?
engine=create_engine(f'postgresql://postgres:root@localhost/GoldPrices')
engine.connect()
#To load ipython-sql
%load_ext sql
%sql postgresql://postgres:root@localhost/GoldPrices
2
Answers
After some google search into it this answer below helped fixing the issue.
I'm not sure what's causing this, but it looks like it's related to SQLAlchemy version 2.0.0. As a temporary workaround, I added !pip install SQLAlchemy==1.4.46 before %load_ext sql, which fixed the problem.
From here https://github.com/catherinedevlin/ipython-sql:
So go here:
https://jupysql.ploomber.io/en/latest/quick-start.html#
and then:
pip install jupysql
With
SQLAlchemy==2.0.23
.Then:
Though if you want to stick with
ipython-sql
, per instructions here:https://github.com/catherinedevlin/ipython-sql
Do the following: