{
  "@context": "https://schema.org",
  "@id": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-08-24-your-executable-is-a-sqlite-database/#webpage",
  "@type": [
    "WebPage",
    "ArchiveComponent"
  ],
  "articleBody": "**[Your executable is a SQLite database](https://fzakaria.com/2026/08/23/your-executable-is-a-sqlite-database)** ([via](https://news.ycombinator.com/item?id=49415271 \"Hacker News\")) Farid Zakaria describes a neat Linux pattern for creating a SQLite database file that can be directly used as an executable binary.\n\nThe trick sets the SQLite file format's 4-byte application ID (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 [this schema](https://github.com/fzakaria/selfdb/blob/main/schema/self.sql).\n\nTheir `self-exec` interpreter ([C code here](https://github.com/fzakaria/selfdb/blob/main/loader/self-exec.c)) can then extract and execute the necessary pieces.\n\nYou can additionally use a Linux mechanism called [binfmt\\_misc](https://docs.kernel.org/admin-guide/binfmt-misc.html) to teach the kernel to execute that any time it encounters an executable matching that binary pattern. Farid uses NixOS here, but without NixOS I think registration looks something like this:\n\n```\nprintf '%s\\n' ':self:M:68:SELF::/usr/local/bin/self-exec:' \\\n  > /proc/sys/fs/binfmt_misc/register\n```\n",
  "authors": [],
  "captured_at": "2026-09-04T12:14:41.802665207+00:00",
  "category": "programming",
  "content_html": "<p><strong><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://fzakaria.com/2026/08/23/your-executable-is-a-sqlite-database\">Your executable is a SQLite database</a></strong> (<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://news.ycombinator.com/item?id=49415271\" title=\"Hacker News\">via</a>) Farid Zakaria describes a neat Linux pattern for creating a SQLite database file that can be directly used as an executable binary.</p>\n<p>The trick sets the SQLite file format's 4-byte application ID (68 bytes into the file) to SELF, standing for Structured Executable &amp; Linkable Format. The various components of the ELF executable format are then arranged into a number of different SQLite tables, using <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/fzakaria/selfdb/blob/main/schema/self.sql\">this schema</a>.</p>\n<p>Their <code>self-exec</code> interpreter (<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://github.com/fzakaria/selfdb/blob/main/loader/self-exec.c\">C code here</a>) can then extract and execute the necessary pieces.</p>\n<p>You can additionally use a Linux mechanism called <a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https://docs.kernel.org/admin-guide/binfmt-misc.html\">binfmt_misc</a> to teach the kernel to execute that any time it encounters an executable matching that binary pattern. Farid uses NixOS here, but without NixOS I think registration looks something like this:</p>\n<pre><code><span class=\"code-snippet\">printf &#39;%s\\n&#39; &#39;:self:M:68:SELF::/usr/local/bin/self-exec:&#39; \\\n  &gt; /proc/sys/fs/binfmt_misc/register\n</span></code></pre>\n",
  "content_markdown": "**[Your executable is a SQLite database](https://fzakaria.com/2026/08/23/your-executable-is-a-sqlite-database)** ([via](https://news.ycombinator.com/item?id=49415271 \"Hacker News\")) Farid Zakaria describes a neat Linux pattern for creating a SQLite database file that can be directly used as an executable binary.\n\nThe trick sets the SQLite file format's 4-byte application ID (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 [this schema](https://github.com/fzakaria/selfdb/blob/main/schema/self.sql).\n\nTheir `self-exec` interpreter ([C code here](https://github.com/fzakaria/selfdb/blob/main/loader/self-exec.c)) can then extract and execute the necessary pieces.\n\nYou can additionally use a Linux mechanism called [binfmt\\_misc](https://docs.kernel.org/admin-guide/binfmt-misc.html) to teach the kernel to execute that any time it encounters an executable matching that binary pattern. Farid uses NixOS here, but without NixOS I think registration looks something like this:\n\n```\nprintf '%s\\n' ':self:M:68:SELF::/usr/local/bin/self-exec:' \\\n  > /proc/sys/fs/binfmt_misc/register\n```\n",
  "dateCreated": "2026-09-04T12:14:41.802665207+00:00",
  "date_created": "2026-08-24T11:38:15+00:00",
  "date_modified": "2026-08-24T11:38:15+00:00",
  "date_published": "2026-08-24T11:38:15+00:00",
  "description": "Your executable is a SQLite database Farid Zakaria describes a neat 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 (68…",
  "external_url": "https://simonwillison.net/2026/Aug/24/your-executable-is-a-sqlite-database/",
  "git": {
    "commit": "ebb0941c5c06a2ab2377342d607535262a3e969e",
    "path": "items/simonwillison-net/2026/08/2026-08-24-your-executable-is-a-sqlite-database.md",
    "permalink": "https://github.com/aymericbeaumet/aggr-instance/blob/ebb0941c5c06a2ab2377342d607535262a3e969e/items/simonwillison-net/2026/08/2026-08-24-your-executable-is-a-sqlite-database.md"
  },
  "id": "urn:aggr:item:825d74dd61f46a54b334d1ef854474230d062d9b",
  "isBasedOn": {
    "@id": "https://simonwillison.net/2026/Aug/24/your-executable-is-a-sqlite-database/"
  },
  "mainEntity": {
    "@id": "https://simonwillison.net/2026/Aug/24/your-executable-is-a-sqlite-database/",
    "@type": "CreativeWork",
    "archivedAt": {
      "@id": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-08-24-your-executable-is-a-sqlite-database/#webpage"
    },
    "dateModified": "2026-08-24T11:38:15+00:00",
    "datePublished": "2026-08-24T11:38:15+00:00",
    "headline": "Your executable is a SQLite database",
    "timeRequired": "PT1M",
    "url": "https://simonwillison.net/2026/Aug/24/your-executable-is-a-sqlite-database/",
    "wordCount": 145
  },
  "name": "Archived snapshot: Your executable is a SQLite database",
  "preview": null,
  "reading_minutes": 1,
  "replicated_at": null,
  "source": "simonwillison-net",
  "source_name": "Simon Willison's Weblog",
  "summary": "Your executable is a SQLite database Farid Zakaria describes a neat 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 (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 this schema. Their self-exec interpreter (C code here) can then extract and execute the necessary pieces. You can additionally use a Linux mechanism called binfmt_misc to teach the kernel to execute that any time it encounters an executable matching that binary pattern. Farid uses NixOS here, but without NixOS I think registration looks something like this: printf '%s\\n' ':self:M:68:SELF::/usr/local/bin/self-exec:' \\ > /proc/sys/fs/binfmt_misc/register Via Hacker News Tags: c, linux, sqlite",
  "tags": [
    "c",
    "linux",
    "sqlite"
  ],
  "temporalCoverage": "2026-09-04T12:14:41.802665207+00:00",
  "title": "Your executable is a SQLite database",
  "url": "https://aggr.aymericbeaumet.com/items/simonwillison-net/2026-08-24-your-executable-is-a-sqlite-database/",
  "word_count": 145
}