DictDB: A Lightweight In-Memory Database for Python

Why DictDB? When prototyping or writing tests, you need a data store as agile as your code. SQLite feels heavy; plain dictionaries lack structure and querying power. DictDB bridges that gap: an in-memory, dictionary-backed database with SQL-like CRUD, optional schemas, indexing, and persistence. No server required. Features Zero Configuration: Import and use. No server, no setup. Query DSL: Fluent interface with Python operators (table.age >= 18). Indexing: Hash indexes for O(1) lookups, sorted indexes for range queries. Optional Schemas: Type validation when you need it. Persistence: Save/load via JSON or Pickle (sync and async). Automatic Backups: Periodic and incremental backup support. Thread Safety: Reader-writer locks for concurrent access. Minimal Dependencies: Only sortedcontainers required. Installation pip install dctdb Note: The PyPI package is dctdb, but the import is dictdb. ...

April 19, 2025 · 2 min · Manoah B.