tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
804 stars 90 forks source link

?sslmode=disable unexpected keyword argument #310

Closed BrentGruber closed 9 months ago

BrentGruber commented 12 months ago

I'm trying to deploy a fastapi/tortoise application to fly.io using one of their provided postgres databases. When you add the database to your application, it creates a default DATABASE_URL environment variable with the full connection string including the parameter ?sslmode=disable

When trying to run aerich upgrade during startup to migrate the database I'm getting the following error

File "/usr/local/lib/python3.11/site-packages/asyncpg/pool.py", line 507, in _get_new_connection
    con = await connection.connect(
                ^^^^^^^^^^^^^^^^^^^
TypeError: connect() got an unexpected keyword argument 'sslmode'

I was able to recreate this error locally using docker-compose and the following connection url

DATABASE_URL=postgres://postgres:postgres@db:5432/web_dev?sslmode=disable

My dependencies

python = "^3.10"
fastapi = "^0.99.1"
uvicorn = "^0.22.0"
asyncpg = "^0.27.0"
tortoise-orm = "^0.19.3"
aerich = "^0.7.1"
httpx = "^0.24.1"

Has anyone successfully passed the sslmode parameter while using tortoise/aerich?

vlakius commented 10 months ago

can you try using ssl=disable instead ?

seems to be a problem on the asyncpg side https://github.com/MagicStack/asyncpg/issues/737 @