postgresql - 通过 EC2 从 sqlalchemy 连接 AWS RDS

我正在尝试使用以下代码从 EC2 机器连接到 AWS RDS (postgres)。当我从本地计算机运行它并在数据库中创建表时,这非常有效。但是当我从 EC2 运行它时,它会抛出一个错误:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection timed out Is the server running on host "" (IP) and accepting TCP/IP connections on port ?

import csv
import boto3

from io import StringIO
from sqlalchemy import create_engine, MetaData, Table, Column, BigInteger, Date,  Integer, String
engine = create_engine('postgresql://<user>:<password>@<host>:<port>/<db>')

table_name = 'checking'
meta = MetaData()

table_name = Table(
   table_name, meta,
   Column('phone', BigInteger, primary_key = True),
   Column('first_name', String),
   schema = 'testing'
)

meta.create_all(engine)

我认为 RDS 或 EC2 存在一些权限问题。在 EC2 上,我可以在任何地方访问 HTTP、HTTPS、TCP、SSH。

最佳答案

哦,我对上面的 postgres 访问没有打开。

https://stackoverflow.com/questions/58851567/

相关文章:

java - 如何禁用 Spring Actuators 的内容协商?

npm - [错误 : Unspecified GSS failure. 次要代码可能提供更多信息:

c# - EFCore 在一对一关系上生成的列名无效

python - Jupyterhub-错误 :asyncio:Task exception was

django - 重定向到 Django Admin 中的过滤列表

reactjs - react Apollo 测试 : MockProvider takes a l

php - 权限被拒绝 : copy/writing file (laravel/php)

typescript - 如何在 Visual Studio CE 2019 中使用#region/

c# - .Net Core Linux 不支持 SecurityIdentifier?

ios - SwiftUI:ScrollView 偏移滚动内容