]> git.openstreetmap.org Git - nominatim.git/blob - docs/customize/SQLite.md
add minimal documentation for the SQLite usage
[nominatim.git] / docs / customize / SQLite.md
1 A Nominatim database can be converted into an SQLite database and used as
2 a read-only source for geocoding queries. This sections describes how to
3 create and use an SQLite database.
4
5 !!! danger
6     This feature is in an experimental state at the moment. Use at your own
7     risk.
8
9 ## Installing prerequisites
10
11 To use a SQLite database, you need to install:
12
13 * SQLite (>= 3.30)
14 * Spatialite (> 5.0.0)
15
16 On Ubuntu/Debian, you can run:
17
18     sudo apt install sqlite3 libsqlite3-mod-spatialite libspatialite7
19
20 ## Creating a new SQLite database
21
22 Nominatim cannot import directly into SQLite database. Instead you have to
23 first create a geocoding database in PostgreSQL by running a
24 [regular Nominatim import](../admin/Import.md).
25
26 Once this is done, the database can be converted to SQLite with
27
28     nominatim convert -o mydb.sqlite
29
30 This will create a database where all geocoding functions are available.
31 Depending on what functions you need, the database can be made smaller:
32
33 * `--without-reverse` omits indexes only needed for reverse geocoding
34 * `--without-search` omit tables and indexes used for forward search
35 * `--without-details` leaves out extra information only available in the
36   details API
37
38 ## Using an SQLite database
39
40 Once you have created the database, you can use it by simply pointing the
41 database DSN to the SQLite file:
42
43     NOMINATIM_DATABASE_DSN=sqlite:dbname=mydb.sqlite
44
45 Please note that SQLite support is only available for the Python frontend. To
46 use the test server with an SQLite database, you therefore need to switch
47 the frontend engine:
48
49     nominatim serve --engine falcon
50
51 You need to install falcon or starlette for this, depending on which engine
52 you choose.
53
54 The CLI query commands and the library interface already use the new Python
55 frontend and therefore work right out of the box.