Simon WillisonTuesday · August 25, 2026FREE

Your executable is a SQLite database

linuxsqliteexecutable

Farid Zakaria describes a Linux pattern for creating a SQLite database file that can be directly used as an executable binary. The trick sets the SQLite file format's 4-byte application ID (located 68 bytes into the file) to SELF, standing for Structured Executable & Linkable Format. The various components of the ELF executable format are then arranged into a number of different SQLite tables, using a schema provided in the source. A self-exec interpreter, written in C, can then extract and execute the necessary pieces. Additionally, a Linux mechanism called binfmt_misc can be used to teach the kernel to execute any file matching that binary pattern. Farid uses NixOS in his example, but without NixOS, registration can be done by writing a line to /proc/sys/fs/binfmt_misc/register. This approach effectively makes an executable file also a queryable database, potentially simplifying data storage and retrieval.

// why it matters

This pattern lets developers create executables that are also SQLite databases, enabling direct querying of binary internals.

Sources

Primary · Simon WillisonMirror · Lobsters
▸ Read original at simonwillison.net

Like this? Get the next digest.