mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
error out when a SQLite database does not exist
Requires to mark the databse r/w when it is newly created in the convert function.
This commit is contained in:
@@ -101,6 +101,10 @@ class NominatimAPIAsync: #pylint: disable=too-many-instance-attributes
|
|||||||
dburl = sa.engine.URL.create('sqlite+aiosqlite',
|
dburl = sa.engine.URL.create('sqlite+aiosqlite',
|
||||||
database=params.get('dbname'))
|
database=params.get('dbname'))
|
||||||
|
|
||||||
|
if not ('NOMINATIM_DATABASE_RW' in self.config.environ
|
||||||
|
and self.config.get_bool('DATABASE_RW')) \
|
||||||
|
and not Path(params.get('dbname', '')).is_file():
|
||||||
|
raise UsageError(f"SQlite database '{params.get('dbname')}' does not exist.")
|
||||||
else:
|
else:
|
||||||
dsn = self.config.get_database_params()
|
dsn = self.config.get_database_params()
|
||||||
query = {k: v for k, v in dsn.items()
|
query = {k: v for k, v in dsn.items()
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ async def convert(project_dir: Path, outfile: Path, options: Set[str]) -> None:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
outapi = napi.NominatimAPIAsync(project_dir,
|
outapi = napi.NominatimAPIAsync(project_dir,
|
||||||
{'NOMINATIM_DATABASE_DSN': f"sqlite:dbname={outfile}"})
|
{'NOMINATIM_DATABASE_DSN': f"sqlite:dbname={outfile}",
|
||||||
|
'NOMINATIM_DATABASE_RW': '1'})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with api.begin() as src, outapi.begin() as dest:
|
async with api.begin() as src, outapi.begin() as dest:
|
||||||
|
|||||||
Reference in New Issue
Block a user