mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-22 12:06:27 +03:00
make sure SQLAlchemy can handle the loaded dialect
The psycopg dialect was only added in SQLAlchemy 2.0. To avoid loading errors when SQLAlchemy 1.4 is installed together with psycopg3, check that the dialect is really available.
This commit is contained in:
parent
e51973f8b1
commit
8cb0d5b262
@ -7,15 +7,17 @@
|
||||
"""
|
||||
Import the base library to use with asynchronous SQLAlchemy.
|
||||
"""
|
||||
# pylint: disable=invalid-name
|
||||
# pylint: disable=invalid-name, ungrouped-imports, unused-import
|
||||
|
||||
from typing import Any
|
||||
|
||||
try:
|
||||
import sqlalchemy.dialects.postgresql.psycopg
|
||||
import psycopg
|
||||
PGCORE_LIB = 'psycopg'
|
||||
PGCORE_ERROR: Any = psycopg.Error
|
||||
except ModuleNotFoundError:
|
||||
import sqlalchemy.dialects.postgresql.asyncpg
|
||||
import asyncpg
|
||||
PGCORE_LIB = 'asyncpg'
|
||||
PGCORE_ERROR = asyncpg.PostgresError
|
||||
|
Loading…
Reference in New Issue
Block a user