skip to Main Content

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 ?

enter image description here

engine=create_engine(f'postgresql://postgres:root@localhost/GoldPrices')
engine.connect()
#To load ipython-sql
%load_ext sql
%sql postgresql://postgres:root@localhost/GoldPrices 

postgresql

2

Answers



  1. From here https://github.com/catherinedevlin/ipython-sql:

    Legacy project

    IPython-SQL’s functionality and maintenance have been eclipsed by JupySQL, a fork maintained and developed by the Ploomber team. Future work will be directed into JupySQL – please file issues there, as well!

    So go here:

    https://jupysql.ploomber.io/en/latest/quick-start.html#

    and then:

    pip install jupysql

    With SQLAlchemy==2.0.23.

    Then:

    %load_ext sql
    from sqlalchemy import create_engine
    db_url = "postgresql://postgres:@localhost/test"
    engine = create_engine(db_url)
    %sql engine
    %sql select * from cell_per
    

    Though if you want to stick with ipython-sql, per instructions here:

    https://github.com/catherinedevlin/ipython-sql

    Do the following:

    %load_ext sql
    %%sql postgresql://postgres:@localhost/test
    select * from cell_per
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search