Embedded

In-process databases that ship inside your app — SQLite, DuckDB and RocksDB.

3 min read 3 lesson sections
  • #sqlite
  • #duckdb
  • #rocksdb
  • #in-process
Embedded: In-process databases that ship inside your app — SQLite, DuckDB and RocksDB.
Concept map

An embedded database is linked to or run inside an application instead of being operated as a separate network service. The application calls the database library directly, and data is often stored in a local file or directory. SQLite provides a full relational engine in a small library; DuckDB focuses on analytical queries, and RocksDB is an embeddable key-value store.

Ask yourself: Does one application on one device own this data, or do many users and services need to share it? That question often points toward embedded or server-based storage.

How an embedded database fits an application

An application opens a database, issues queries or key operations through its library API, and closes it when appropriate. With SQLite, for example, the database can be a file shipped with a desktop or mobile app. There is no separate database server to install, configure, monitor, or secure over a network.

This simplicity has trade-offs. Multiple processes may compete to write the same file, and many embedded engines serialize writes or are optimized for a single machine. A local file also does not automatically provide remote access, replication, or centralized user permissions.

A small SQLite example

CREATE TABLE notes (
  id INTEGER PRIMARY KEY,
  title TEXT NOT NULL,
  body TEXT NOT NULL,
  updated_at TEXT NOT NULL
);

INSERT INTO notes (title, body, updated_at)
VALUES ('First note', 'Saved in a local database.', CURRENT_TIMESTAMP);

SELECT id, title, updated_at
FROM notes
ORDER BY updated_at DESC;

The schema and SQL are relational, but the database engine runs within the host application rather than as an independent service. Use parameterized queries from application code for user-provided values; do not build SQL by concatenating untrusted text.

Where embedded databases work well

  • Desktop and mobile applications that need reliable local data.
  • Command-line tools and local caches that should work without network access.
  • Tests that need a quick, disposable database.
  • Single-node analytics on files or locally collected data.

Choose a client-server database when many machines need concurrent access, centralized administration, or high write throughput. Before shipping an embedded database, plan for file permissions, schema upgrades, backups, corruption recovery, and encryption requirements. A database file is application data and should be protected accordingly.