Spaces:
Running
Running
Download app/core/database_url.py from basyx/MediaRouter: direct link, hf CLI and curl.
- Browser
- Download file 767 Bytes
-
https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/app/core/database_url.py
- Command line
-
hf download hf://spaces/basyx/MediaRouter/app/core/database_url.py
-
curl -L -o database_url.py https://huggingface.co/spaces/basyx/MediaRouter/resolve/main/app/core/database_url.py
767 Bytes
| from __future__ import annotations | |
| def normalize_async_database_url(value: str) -> str: | |
| """Use the installed asyncpg dialect for bare PostgreSQL URLs. | |
| Operators frequently supply a standard ``postgresql://`` URL. SQLAlchemy | |
| otherwise selects synchronous psycopg2 for that form, which fails inside | |
| this async application and can tempt deployments to add an unnecessary | |
| synchronous driver. Explicit dialect URLs remain unchanged. | |
| """ | |
| normalized = value.strip() | |
| if normalized.startswith("postgresql://"): | |
| return "postgresql+asyncpg://" + normalized.removeprefix("postgresql://") | |
| if normalized.startswith("postgres://"): | |
| return "postgresql+asyncpg://" + normalized.removeprefix("postgres://") | |
| return normalized | |