Skip to content

Commit 3c05d98

Browse files
committed
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.
1 parent 7bbdf57 commit 3c05d98

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

nominatim/clicmd/replication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _update(self, args: NominatimArgs) -> None:
142142
if not args.do_index:
143143
LOG.fatal("Indexing cannot be disabled when running updates continuously.")
144144
raise UsageError("Bad argument '--no-index'.")
145-
recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL')
145+
recheck_interval = args.config.get_int('REPLICATION_RECHECK_INTERVAL')
146146

147147
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
148148
indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, args.threads or 1)

nominatim/db/async_core_library.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
"""
88
Import the base library to use with asynchronous SQLAlchemy.
99
"""
10-
# pylint: disable=invalid-name
10+
# pylint: disable=invalid-name, ungrouped-imports, unused-import
1111

1212
from typing import Any
1313

1414
try:
15+
import sqlalchemy.dialects.postgresql.psycopg
1516
import psycopg
1617
PGCORE_LIB = 'psycopg'
1718
PGCORE_ERROR: Any = psycopg.Error
1819
except ModuleNotFoundError:
20+
import sqlalchemy.dialects.postgresql.asyncpg
1921
import asyncpg
2022
PGCORE_LIB = 'asyncpg'
2123
PGCORE_ERROR = asyncpg.PostgresError

0 commit comments

Comments
 (0)