I'm trying to connect to a postgres db with python but i'm not sure of the connection logic. I have:
host_name = "my_db-db.cluster-XXXXXX.us-east-1.rds.amazonaws.com"
username = "postgres"
dbname = "my_db"
password = "my_password"
port = "5678"
I've tried using:
from sqlalchemy import *
engine =
create_engine('postgresql://postgres:my_password@localhost:5678/my_db')
engine.connect()
How do I adjust the engine term to establish a connection?
Replace localhost
with the RDS host name.
from sqlalchemy import *
engine =
create_engine('postgresql://postgres:my_password@my_db-db.cluster-XXXXXX.us-east-1.rds.amazonaws.com:5678/my_db')
engine.connect()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.