๐Ÿ—„๏ธ
๐Ÿ—„๏ธ Data & Storage with the Larz Stack ยท LARZ-701 ยท Session 1 of 4

Storage Without a Database Server

Most projects reach for Postgres on day one - and take on a server to run, secure and back up. Often you don't need to. larzdb gives you crash-safe, single-file storage with zero setup.

โฑ 8 min read๐Ÿ“… Updated 2026-07-27๐Ÿ“Š Tables, charts & examples

Reaching for a database server like Postgres on day one is a common reflex - and often overkill for a new app, a tool, or a prototype. It's a whole service to run, secure, back up and pay for. The stack's larzdb offers an alternative: a crash-safe database in a single file, with zero setup and zero dependencies, that's genuinely enough for a lot of real work.

A whole database in one file

larzdb is a log-structured, crash-safe embedded database - your whole dataset lives in one file, and it survives interrupted writes.

FeatureWhat it gives you
Single-file, embeddedNo server to run, secure or back up
Crash-safe (CRC + fsync)Interrupted writes can't corrupt your data
JSON document collectionsStore and query objects, not just rows
Indexes + transactionsFast lookups and all-or-nothing changes

It's log-structured with CRC-checked frames and fsync-on-commit, so a power loss mid-write drops the torn tail on replay rather than corrupting the database - real durability in a file.

Use it like a database

You get key-value storage and JSON document collections with a Mongo-style query language - enough for most app data.

from larzdb import Database
db = Database('app.db')
users = db.collection('users')
users.insert({'email': 'ada@x.com', 'plan': 'pro'})
users.find({'plan': 'pro'})            # query by fields
with db.transaction():                 # atomic
    users.update({'email':'ada@x.com'}, {'plan':'free'})
๐ŸŽฏ
Start simple, graduate when you actually need to. larzdb is genuinely suitable for prototypes, tools, and small-to-medium apps - a real database with no server. When you truly outgrow it (high write concurrency, huge datasets), you move to a database server using larzsql + larzmigrate (next sessions) without rewriting your whole data layer. Don't take on database-server complexity before you need it.

When to use it

  • Prototypes & tools - a real DB with zero setup.
  • Small-to-medium apps - crash-safe, indexed, transactional.
  • JSON documents - store objects with a query language.
  • Graduate later - move to a server via larzsql when you outgrow it.

๐Ÿงฉ Do it with LarzOS

Turn this lesson into action with the exact free tools and AI workflows for the job:

๐ŸŽฏ Key takeaways

  • You often don't need a database server on day one - larzdb is a crash-safe DB in a single file.
  • It's log-structured with CRC + fsync, so interrupted writes drop the torn tail instead of corrupting data.
  • You get key-value storage plus JSON document collections with queries, indexes and transactions.
  • Great for prototypes/tools/small-medium apps; graduate to a server via larzsql when you truly outgrow it.

Frequently asked

Is a single-file database really safe for real data?

For a lot of real use, yes. larzdb is specifically engineered for durability: it's log-structured, checksums every frame with CRC, and fsyncs on commit, so if the process or power dies mid-write, the incomplete tail is detected and dropped on the next open rather than corrupting your data - it's tested against exactly these crash scenarios. That makes it genuinely appropriate for prototypes, background tools, and small-to-medium applications. Its limits are concurrency and scale: for many simultaneous writers or very large datasets you'd move to a database server. But 'single file' doesn't mean 'unsafe' - it means simple, and larzdb takes durability seriously.

When should I use larzdb versus a real database server?

Use larzdb when simplicity wins: prototypes, personal tools, single-server apps, and small-to-medium workloads where you'd rather not run, secure and back up a separate database service. Move to a database server (Postgres, etc.) when you genuinely hit its limits - high write concurrency from many processes, very large datasets, or a need for features a server provides. The good news is the transition isn't a rewrite: you build queries with larzsql and manage schema with larzmigrate (the next sessions), which work against real DB-API databases too, so your data layer stays familiar. Start simple, and upgrade only when the need is real, not hypothetical.

Session 1 of 4 complete

Next up: Injection-Safe Queries with larzsql

Continue to Session 2 โ†’

Related lessons

More in this course

Course home → · Browse all courses →