[英]PostgresSQL on Amazon RDS
I have configured a PostgresSQL database instance on Amazon RDS and want to use it from the python script.我已经在 Amazon RDS 上配置了一个 PostgresSQL 数据库实例,并想从 python 脚本中使用它。 I am using awswrangler for it.
我正在使用 awswrangler。
Below is the python script.下面是python脚本。
import awswrangler as wr
df1 = pd.DataFrame({
"id": [1, 2],
"name": ["foo", "boo"]
})
eng_postgresql = wr.db.get_engine(db_type="postgresql", host=ENDPOINT, port=5432, database=DBNAME, user=USR, password=pass)
wr.db.to_sql(df1, eng_postgresql, schema="public", name="tutorial", if_exists="replace", index=False) # PostgreSQL
I am getting the below error:我收到以下错误:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Operation timed out
Is the server running on host "*************.rds.amazonaws.com" (172.31.23.226) and accepting
TCP/IP connections on port 5432?
Based on the comments.根据评论。
The connection time outs due to the fact that the RDS is not public .由于 RDS不是公开的,连接超时。 Subsequently, connections over the internet will fail.
随后,通过 Internet 的连接将失败。
There are generally three solutions to this problem;这个问题一般有三种解决方案;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.