Using a synchronous engine we do the following and it works:
engine = create_engine(
"postgresql+psycopg2://USER:PASS@XXX.us-east-1.rds.amazonaws.com/dbname",
pool_pre_ping=True,
connect_args={"sslmode": "verify-full", "sslrootcert": 'path/to/cert'},
future=True,
echo=False,
)
But when using the same for async it doesn't work for me:
engine = create_async_engine(
"postgresql+asyncpg://USER:PASS@XXX.us-east-1.rds.amazonaws.com/dbname",
pool_pre_ping=True,
connect_args={"sslmode": "verify-full", "sslrootcert": 'path/to/cert'},
future=True,
echo=False,
)
The error is rather lengthy but ends simply with:
File "/Users/chhenning/.pyenv/versions/cooper/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/asyncpg.py", line 777, in connect
await_only(self.asyncpg.connect(*arg, **kw)),
TypeError: connect() got an unexpected keyword argument 'sslmode'
As far as I can tell asyncpg can deal with ssl. Link here:
https://magicstack.github.io/asyncpg/current/api/index.html#connection
Is there a way to pass arguments to the underlying db driver when calling create_async_engine?