Closed
Description
- asyncpg version: 0.18.3
I am using asyncpg to connect to a Azure PostgreSQL database, and Azure imposes the use of a username of the form name@db
, so the full connection url looks like:
postgresql://my-user@my-db-server:my-password@my-db-server.postgres.database.azure.com:5432/some-db
When using such an url to connect with asyncpg, I get the following error:
File "/home/victor/.local/share/virtualenvs/datapipe-3ZEOKy8g/lib/python3.7/site-packages/asyncpg/connect_utils.py", line 187, in _parse_hostlist
hostlist_ports.append(int(hostspec_port))
ValueError: invalid literal for int() with base 10: 'my-password@my-db-server.postgres.database.azure.com:5432'
I see two problems here:
- the password leak in the logs (even tough I'm not sure how to avoid this in a consistent manner…)
- the fact that asyncpg incorrectly split the
netloc
part of the uri by splitting at the first@
intead of the last one.
The ticket is about the second problem:
- I think it should be safe to assume that everything before the last
@
in thenetloc
is for authentication. - Also by the way, it should also be safe to assume that everything after the first
:
in the auth part to be the password.
For the record, when using sqlalchemy + psycogs2, I have no problem using this kind of url to connect to my database.
Metadata
Metadata
Assignees
Labels
No labels