Forums

connect remote to my postgresql

I need help please. am trying to connect from outside pythonanywhere, to my PostgreSQL database, but with out luck till now my connection string is: engine = create_engine('postgresql+psycopg2://*:**@*-2737.postgres.pythonanywhere-services.com:12737/mydb')

I don't now what i did wrong

The error am getting is: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not translate host name "*@*-2737.postgres.pythonanywhere-services.com" to address: nodename nor servname provided, or not known

You need to use SSH tunneling for that, see the help page.

Thank you ... am using sqlalchemy do i have to change everything to use SSH tunneling, is there any way to use aqlachemy library with Postgresql

this my code for the connection

from sqlalchemy import create_engine, MetaData

engine = create_engine('postgresql+psycopg2://:@**-2737.postgres.pythonanywhere-services.com:12737/mydb')

meta=MetaData()

conn=engine.connect()

Yes, the SSH tunnel is required, you will not be able to connect without it.