Skip to content

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

Open
@CodeBardian

Description

@CodeBardian
  • asyncpg version: 0.29.0
  • PostgreSQL version: 16.2
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : local
  • Python version: 3.12
  • Platform: Win
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    :

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions