【发布时间】:2021-03-27 12:33:17
【问题描述】:
我一直试图弄清楚是否有任何方法可以为通过 DataAPI 使用的 Aurora Serverless (Postgresql) DB 提供 ORM 功能(尤其是代码模型生成)?最终,我想避免在我们的 Lambda 中使用原始 sql 字符串查询。
我尝试将sqlacodegen 与sqlalchemy-aurora-data-api 结合使用(在sqlalchemy 之上工作),但我不断收到错误:
有方言:
> sqlacodegen postgresql+auroradataapi://username:password@db-host/db-name
botocore.exceptions.NoRegionError: 你必须指定一个区域。
没有方言:
> sqlacodegen postgresql://username:password@db-host/db-name
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) 无法连接到服务器:连接超时 (0x0000274C/10060)
前者似乎暗示必须将参数传递给调用,但 sqlacodegen 不接受任何 kwargs afaik。后者只是无法连接,psycopg2 告诉我它只是没有使用正确的方言。
【问题讨论】:
标签: python postgresql orm sqlalchemy aws-aurora-serverless