Replacing MariaDB with SQLite3

Are there guides that I could be pointed to if we want to remove the MariaDB service defined in docker-compose.yml and replace it with SQLite3?

I don’t use SQLite so I’m not very familiar with it but I believe it’s a file based database so we can’t really have it as a separate service, the way I see it, the SQLite database should be included in the backend service. Also, how much modifications would it be on the backend service to get this working?


Which problem do you want to solve by doing that change?

This is probably a fairly serious lift to make happen. OpenMRS uses Hibernate (for the most part), which is generally database-agnostic. However, the version of Hibernate we are using does not have support for SQLite. There are some versions of Hibernate “dialects” to talk to SQLite, but none of them (until the 6.x release) are officially supported.

At a minimum, to get this to work, you would need to include a Hibernate dialect for SQLite as a JAR, the JDBC driver for SQLite. Then the real problem, which is that while we use Hibernate for most database access, the part of the program that creates the tables, etc. is done in Liquibase. These liquibase scripts are generally written in raw SQL and the SQL dialect may not be appropriate for SQLite, since each DB implements it’s own version of SQL. Likely, you need to spend some time editing the liquibase files, both for the OpenMRS core and each module you wished to use to get them to work on SQLite.

Finally, SQLite isn’t an appropriate choice if you need other processes to query the database, i.e. for reports run outside the EMR, etc.