Why SQLite makes a good embedded device application store

Reliability

From SQLite Is Transactional :

SQLite is Transactional

A transactional database is one in which all changes and queries appear to be Atomic, Consistent, Isolated, and Durable (ACID). SQLite implements serializable transactions that are atomic, consistent, isolated, and durable, even if the transaction is interrupted by a program crash, an operating system crash, or a power failure to the computer.

We here restate and amplify the previous sentence for emphasis: All changes within a single transaction in SQLite either occur completely or not at all, even if the act of writing the change out to the disk is interrupted by

  • a program crash,
  • an operating system crash, or
  • a power failure.

The claim of the previous paragraph is extensively checked in the SQLite regression test suite using a special test harness that simulates the effects on a database file of operating system crashes and power failures.

Additional information

This is why SQLite is a very interesting method for storing configuration information on embedded edge devices where the environment is anything but certain.

Portability

SQLite file format will not change in ways that might break future systems from reading the file.

https://www.sqlite.com/formatchng.html

https://www2.sqlite.org/draft/sqlar.html

Speed

https://www.sqlite.org/fasterthanfs.html

https://www.sqlite.org/speed.html

Other notes

https://www.sqlite.org/whentouse.html

1 Like

Added a section to the SIOT docs on this topic:

https://docs.simpleiot.org/docs/ref/store.html#reasons-for-using-sqlite