beaver is a simple, local, and embedded database designed to manage complex, modern data types without requiring a database server, built on top of SQLite.
Design Philosophy
beaver is built with a minimalistic philosophy for small, local use cases where a full-blown database server would be overkill.
- Minimal Dependencies: The core library has minimal dependencies (
numpy,pydantic,rich,typer). Advanced features (like the REST server) are optional extras. - Safe Concurrency: Thread-safe and multi-process-safe by default, with robust inter-process locking.
- Local-First: A single, portable SQLite file is the default.
- Fast & Performant: Zero network latency for local operations and an optional, in-memory read cache.
- Standard SQLite: The database file is 100% compatible with any standard SQLite tool, ensuring data portability.
- Pythonic API: Designed to feel like a natural extension of your code, using standard Python data structures and Pydantic models.
Installation
Install the core library:
pip install beaver-db
Quickstart
Get up and running in 30 seconds. This example showcases a dictionary, a list, and full-text search in a single script.
from beaver import BeaverDB, Document
# 1. Initialize the database
db = BeaverDB("data.db")
# 2. Use a namespaced dictionary for app configuration
config = db.dict("app_config")
config["theme"] = "dark"
print(f"Theme set to: {config['theme']}")
# 3. Use a persistent list to manage a task queue
tasks = db.list("daily_tasks")
tasks.push("Write the project report")
tasks.push("Deploy the new feature")
print(f"First task is: {tasks[0]}")
# 4. Use a document collection for storage + full-text search
articles = db.docs("articles")
doc = Document(
id="sqlite-001",
body="SQLite is a powerful embedded database ideal for local apps.",
)
articles.index(document=doc)
# Perform a full-text search
results = articles.search("database")
top = results[0]
print(f"FTS Result: '{top.document.body}' (score={top.score:.2f})")
db.close()
Features
- Key-Value Dictionaries: A Pythonic, dictionary-like interface for storing any JSON-serializable object or Pydantic model within separate namespaces. Includes TTL support for caching.
- Blob Storage: A dictionary-like interface for storing binary data (e.g., images, PDFs) with associated JSON metadata.
- Persistent Lists: A full-featured, persistent Python list supporting
push,pop,prepend,deque, slicing, and in-place updates. - Persistent Priority Queue: A high-performance, persistent priority queue perfect for task orchestration across multiple processes.
- Probabilistic Sketches: Track cardinality and membership for millions of items in constant space using HyperLogLog and Bloom Filters.
- Document Collections: Store rich documents combining a vector embedding and Pydantic-based metadata.
- Vector Search: Fast, multi-process-safe linear vector search using an in-memory
numpy-based index. - Full-Text & Fuzzy Search: Automatically index and search through document metadata using SQLite's FTS5 engine, with optional fuzzy search for typo-tolerant matching.
- Knowledge Graph: Create directed, labeled relationships between documents and traverse the graph to find neighbors or perform multi-hop walks.
- Pub/Sub System: A powerful, thread and process-safe publish-subscribe system for real-time messaging with a fan-out architecture.
- Time-Indexed Logs: A specialized data structure for structured, time-series logs. Query historical data by time range or create a live, aggregated view.
- Event-Driven Callbacks: Listen for database changes in real-time. Subscribe to events on specific managers to trigger workflows or update UIs.
- Inter-Process Locking: Robust, deadlock-proof locks. Use
db.lock('task_name')to coordinate arbitrary scripts, orwith db.list('my_list') as l:to perform atomic, multi-step operations. - Pydantic Support: Optionally associate
pydantic.BaseModels with any data structure for automatic, recursive data validation and (de)serialization. - Data Export: Dump most data structures to a portable JSON file with a single
.dump()command. (Full backup/restore symmetry —.load()across all managers, plus thebeaverCLI and REST server — lands in2.0final; tracked in issues #15, #18, #36.)
Documentation
For a complete API reference, in-depth guides, and more examples, please visit the official documentation at:
Contributing
Contributions are welcome! If you think of something that would make beaver more useful for your use case, please open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Metadata
Release files for beaver-db 2.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| beaver_db-2.4.2.tar.gz | 1.6 MB | Without provenance | Details for beaver_db-2.4.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| beaver_db-2.4.2-py3-none-any.whl | Python 3 | none | any | Details for beaver_db-2.4.2-py3-none-any.whl |
Total release size: 1.7 MB
Release files / beaver_db-2.4.2.tar.gz
| Download URL | beaver_db-2.4.2.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
83365c5f8d1a39907dbc193112f412d4dec132ac944ba84b3e8d584207062fa8
|
|
BLAKE2b-256 checksum How to use checksums |
728b7a65828b20032da3983464cd9cb91235bd4b6ff59cba68fbc797d10fd5cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / beaver_db-2.4.2-py3-none-any.whl
| Download URL | beaver_db-2.4.2-py3-none-any.whl |
|---|---|
| Size | 88.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74376d46f629aff4248812ae4bf87271383f1175f1f4c403bdb364d0b25503db
|
|
BLAKE2b-256 checksum How to use checksums |
2d6515756223dd922c23f7df940541c98a4f82b798be79f6a5b536a5d625501d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for beaver-db 2.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.