MagicStack / asyncpg

A fast PostgreSQL Database Client Library for Python/asyncio.
Apache License 2.0
6.88k stars 399 forks source link

Does asyncpg support using `pg_service.conf` for connection parameters? #1172

Open CodeBardian opened 1 month ago

CodeBardian commented 1 month ago

I have a pg_service.conf (https://www.postgresql.org/docs/current/libpq-pgservice.html) that holds all required connection parameters.

[mydb]
host=localhost
port=5432
user=postgres
password=test

I can successfully connect with psycopg2 (or sqlalchemy) using psycopg2.connect("postgresql://?service=mydb")

Using await asyncpg.connect("postgresql://?service=mydb") however always fails with

asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation

Also when using the same connection string in sqlachemy with asyncpg dialect, the connection call is converted to

await asyncpg.connect(service='mydb'), which also fails: connect() got an unexpected keyword argument 'service'

So therefore my general question, whether there is support for this type of connection in asyncpg?