💬 观点Simon Willison
Your executable is a SQLite database — 把 SQLite 数据库文件直接当可执行程序运行,一个 Linux 上的巧妙技巧
把 SQLite 数据库文件直接当可执行程序运行,一个 Linux 上的巧妙技巧。
2026-08-24原文
本文为要点摘要,完整细节以原文为准。
🧭 一图看懂
由原文自动提炼 · 以原文为准点击任一分支,查看这一点的一句话解读
SQLite 文件当可执行程序
把 SQLite 数据库文件直接当 Linux 可执行二进制运行
- 文件第 68 字节的 4 字节应用 ID 设为 SELF
- SELF 意为 Structured Executable &…
⚙️ 流程拆解
STEP 1设置应用 ID 为 SELF
STEP 2按 schema 把 ELF 存入表
STEP 3编写 self-exec 解释器
STEP 4注册 binfmt_misc
STEP 5内核匹配并执行
🔗 涉及的概念与玩家
- SQLite产品
- ELF概念
- SELF概念
- binfmt_misc方法
- Farid Zakaria人物
- Simon Willison人物
- NixOS产品
- self-exec产品
- Farid Zakaria—提出→SELF
- SELF—基于→SQLite
- SELF—封装→ELF
- binfmt_misc—识别执行→SELF
- self-exec—解释执行→SELF
- Simon Willison—介绍→Farid Zakaria
- Farid Zakaria 提出利用 SQLite 文件格式中的 4 字节应用 ID(偏移 68 字节)设为
SELF,将 ELF 可执行文件的各组件存入 SQLite 表,实现“数据库即可执行文件”。 - 通过
binfmt_misc机制,内核可识别该模式并调用解释器执行,无需 NixOS 也能注册,如写入/proc/sys/fs/binfmt_misc/register。 - 对开发者而言,这展示了文件格式的灵活性和系统扩展性,启发将数据与代码融合的新思路,但需注意安全性和兼容性。
原文:Your executable is a SQLite database · 作者 Simon Willison
🕸 顺着图谱继续读
- Any Nix package, live in your browser — Nix 包在浏览器里跑起来:qemu2026-09-10 · 共同涉及 Farid Zakaria、Simon Willison
- datasette-explain 0.2.2 — Datasette 查询解释插件更新,让只读存储查询页也能看执行计划2026-09-20 · 共同涉及 Simon Willison、SQLite
- github-to-sqlite 2.9.1 — Simon Willison 发布 github2026-09-11 · 共同涉及 Simon Willison、SQLite
- sqlite-utils 4.2.1 — sqlite2026-08-13 · 共同涉及 Simon Willison、SQLite