SQLite

  • data
  • in current work

I genuinely love SQLite. There's something beautiful about a database that's just a .db file you can copy, move, or throw on a USB stick. No server, no configuration, no ports to open. It just works.

It was the first database I used in LoS (back when the whole app was local-only on my phone) and it powered the inventory system in Free Clothes too. For both projects, the simplicity of having everything self-contained in one file was exactly right. Eventually, LoS outgrew it when I needed concurrent access from multiple devices, and I migrated to PostgreSQL. And it's what my Obsidian plugin queries: SQL in a note, run against a .db file.

It has quirks: booleans are stored as 0 and 1, there's no native list type, and the single-writer model means write-heavy workloads can bottleneck. But for embedded apps, prototyping, or anything where you want a real SQL database without the overhead of running a server, nothing else comes close.

sqliteDB/src/webcomponents/services/HabitDataService.tslines 72–86 on GitHub
if (existingUuid && typeof existingUuid === 'string') {
    const updateSql = `UPDATE ${safeTable} SET ${safeValueCol} = ?, ${updatedAtCol} = ? WHERE uuid = ?`;
    const updateParams = [args.newValue, now, existingUuid];
    await this.dbService.runQuery(updateSql, updateParams);
} else {
    const insertSql = `
        INSERT INTO ${safeTable} (${safeHabitIdCol}, ${safeDateCol}, ${safeValueCol}, ${updatedAtCol})
        VALUES (?, ?, ?, ?)
        ON CONFLICT(${safeHabitIdCol}, ${safeDateCol}) DO UPDATE SET
            ${safeValueCol} = excluded.${safeValueCol},
            ${updatedAtCol} = excluded.${updatedAtCol};
    `;
    const insertParams = [args.habitKey, args.date, args.newValue, now];
    await this.dbService.runQuery(insertSql, insertParams);
}