forked from hans/Nominatim
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:
@@ -142,7 +142,7 @@ class UpdateReplication:
|
|||||||
if not args.do_index:
|
if not args.do_index:
|
||||||
LOG.fatal("Indexing cannot be disabled when running updates continuously.")
|
LOG.fatal("Indexing cannot be disabled when running updates continuously.")
|
||||||
raise UsageError("Bad argument '--no-index'.")
|
raise UsageError("Bad argument '--no-index'.")
|
||||||
recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL')
|
recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL')
|
||||||
|
|
||||||
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
||||||
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, args.threads or 1)
|
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, args.threads or 1)
|
||||||
|
|||||||
@@ -7,15 +7,17 @@
|
|||||||
"""
|
"""
|
||||||
Import the base library to use with asynchronous SQLAlchemy.
|
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
|
from typing import Any
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
import sqlalchemy.dialects.postgresql.psycopg
|
||||||
import psycopg
|
import psycopg
|
||||||
PGCORE_LIB = 'psycopg'
|
PGCORE_LIB = 'psycopg'
|
||||||
PGCORE_ERROR: Any = psycopg.Error
|
PGCORE_ERROR: Any = psycopg.Error
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
|
import sqlalchemy.dialects.postgresql.asyncpg
|
||||||
import asyncpg
|
import asyncpg
|
||||||
PGCORE_LIB = 'asyncpg'
|
PGCORE_LIB = 'asyncpg'
|
||||||
PGCORE_ERROR = asyncpg.PostgresError
|
PGCORE_ERROR = asyncpg.PostgresError
|
||||||
|
|||||||
Reference in New Issue
Block a user