Rewrite a bare postgres(ql):// URI to use the psycopg3 driver scheme postgresql+psycopg://. URIs that already carry a driver specifier (e.g. postgresql+psycopg://) are returned unchanged.
(uri)
| 11 | |
| 12 | |
| 13 | def normalize_database_uri(uri): |
| 14 | """ |
| 15 | Rewrite a bare postgres(ql):// URI to use the psycopg3 driver scheme |
| 16 | postgresql+psycopg://. URIs that already carry a driver specifier |
| 17 | (e.g. postgresql+psycopg://) are returned unchanged. |
| 18 | """ |
| 19 | return re.sub(r"^postgres(?:ql)?://", |
| 20 | "postgresql+psycopg://", uri, count=1) |
no outgoing calls