]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/core.py
error out when a SQLite database does not exist
[nominatim.git] / nominatim / api / core.py
index f975f44aaec39b3e358329f67c0c0da70f702017..1c0c4423fcae0c6a82d07c39c690bd1b14ffbb47 100644 (file)
@@ -101,6 +101,10 @@ class NominatimAPIAsync: #pylint: disable=too-many-instance-attributes
                 dburl = sa.engine.URL.create('sqlite+aiosqlite',
                                              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:
                 dsn = self.config.get_database_params()
                 query = {k: v for k, v in dsn.items()