mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 13:24:07 +00:00
make DB helper functions free functions
Also changes the drop function so that it can drop multiple tables at once.
This commit is contained in:
@@ -12,7 +12,7 @@ import argparse
|
||||
import random
|
||||
|
||||
from ..errors import UsageError
|
||||
from ..db.connection import connect
|
||||
from ..db.connection import connect, table_exists
|
||||
from .args import NominatimArgs
|
||||
|
||||
# Do not repeat documentation of subcommand classes.
|
||||
@@ -115,7 +115,7 @@ class AdminFuncs:
|
||||
|
||||
tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config)
|
||||
with connect(args.config.get_libpq_dsn()) as conn:
|
||||
if conn.table_exists('search_name'):
|
||||
if table_exists(conn, 'search_name'):
|
||||
words = tokenizer.most_frequent_words(conn, 1000)
|
||||
else:
|
||||
words = []
|
||||
|
||||
@@ -13,7 +13,7 @@ import logging
|
||||
from pathlib import Path
|
||||
|
||||
from ..config import Configuration
|
||||
from ..db.connection import connect
|
||||
from ..db.connection import connect, table_exists
|
||||
from ..tokenizer.base import AbstractTokenizer
|
||||
from .args import NominatimArgs
|
||||
|
||||
@@ -124,7 +124,7 @@ class UpdateRefresh:
|
||||
with connect(args.config.get_libpq_dsn()) as conn:
|
||||
# If the table did not exist before, then the importance code
|
||||
# needs to be enabled.
|
||||
if not conn.table_exists('secondary_importance'):
|
||||
if not table_exists(conn, 'secondary_importance'):
|
||||
args.functions = True
|
||||
|
||||
LOG.warning('Import secondary importance raster data from %s', args.project_dir)
|
||||
|
||||
Reference in New Issue
Block a user