Convert a synchronous DB URL to its async dialect equivalent.
(url: str)
| 8 | |
| 9 | |
| 10 | def to_async_url(url: str) -> str: |
| 11 | """Convert a synchronous DB URL to its async dialect equivalent.""" |
| 12 | if url.startswith("sqlite:///"): |
| 13 | return url.replace("sqlite:///", "sqlite+aiosqlite:///", 1) |
| 14 | if url.startswith("postgresql://"): |
| 15 | return url.replace("postgresql://", "postgresql+asyncpg://", 1) |
| 16 | if url.startswith("mysql://"): |
| 17 | return url.replace("mysql://", "mysql+aiomysql://", 1) |
| 18 | return url |
| 19 | |
| 20 | |
| 21 | async def async_run_with_retry_session( |
no outgoing calls