From ab45db5360aab95bd2ef1f09a87fa1c105a4fa46 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 9 Dec 2023 16:30:31 +0100 Subject: [PATCH] add minimal documentation for the SQLite usage --- docs/customize/SQLite.md | 55 ++++++++++++++++++++++++++++++++++++++++ docs/mkdocs.yml | 1 + 2 files changed, 56 insertions(+) create mode 100644 docs/customize/SQLite.md diff --git a/docs/customize/SQLite.md b/docs/customize/SQLite.md new file mode 100644 index 00000000..9614feab --- /dev/null +++ b/docs/customize/SQLite.md @@ -0,0 +1,55 @@ +A Nominatim database can be converted into an SQLite database and used as +a read-only source for geocoding queries. This sections describes how to +create and use an SQLite database. + +!!! danger + This feature is in an experimental state at the moment. Use at your own + risk. + +## Installing prerequisites + +To use a SQLite database, you need to install: + +* SQLite (>= 3.30) +* Spatialite (> 5.0.0) + +On Ubuntu/Debian, you can run: + + sudo apt install sqlite3 libsqlite3-mod-spatialite libspatialite7 + +## Creating a new SQLite database + +Nominatim cannot import directly into SQLite database. Instead you have to +first create a geocoding database in PostgreSQL by running a +[regular Nominatim import](../admin/Import.md). + +Once this is done, the database can be converted to SQLite with + + nominatim convert -o mydb.sqlite + +This will create a database where all geocoding functions are available. +Depending on what functions you need, the database can be made smaller: + +* `--without-reverse` omits indexes only needed for reverse geocoding +* `--without-search` omit tables and indexes used for forward search +* `--without-details` leaves out extra information only available in the + details API + +## Using an SQLite database + +Once you have created the database, you can use it by simply pointing the +database DSN to the SQLite file: + + NOMINATIM_DATABASE_DSN=sqlite:dbname=mydb.sqlite + +Please note that SQLite support is only available for the Python frontend. To +use the test server with an SQLite database, you therefore need to switch +the frontend engine: + + nominatim serve --engine falcon + +You need to install falcon or starlette for this, depending on which engine +you choose. + +The CLI query commands and the library interface already use the new Python +frontend and therefore work right out of the box. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 3301356d..f332640f 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -40,6 +40,7 @@ nav: - 'Special Phrases': 'customize/Special-Phrases.md' - 'External data: US housenumbers from TIGER': 'customize/Tiger.md' - 'External data: Postcodes': 'customize/Postcodes.md' + - 'Conversion to SQLite': 'customize/SQLite.md' - 'Library Guide': - 'Getting Started': 'library/Getting-Started.md' - 'Nominatim API class': 'library/NominatimAPI.md' -- 2.45.2