Skip to main content

Nondb

A simple, filesystem-based document store for Pydantic-modeled JSON data.

Purpose

Nondb is a lightweight document database that uses the filesystem for storage and Pydantic models for data validation and serialization. It provides a simple interface for storing, retrieving, and querying JSON documents while leveraging Pydantic's powerful data validation capabilities.

Perfect for:

  • Small to medium-sized applications that need structured data storage
  • Prototypes and development environments
  • Applications that benefit from human-readable, file-based data storage

Features

  • Pydantic Integration: Automatic JSON serialization/deserialization using Pydantic models
  • Type Safety: Full type checking and validation through Pydantic
  • Filesystem Storage: Human-readable JSON files organized in directories
  • Flexible Keys: Customizable key expressions using JMESPath syntax
  • Secondary Indexing: Create indices on any field for fast lookups
  • Multiple Tables: Support for multiple data models in a single database
  • Simple API: Intuitive interface for CRUD operations

Installation

pip install nondb

Or install from source:

git clone https://github.com/slank/nondb.git
cd nondb
pip install -e .

Usage Examples

Basic Usage

from pydantic import BaseModel
from nondb import NoDB

# Define your data model
class User(BaseModel):
    id: int
    name: str
    email: str
    age: int

# Initialize database
db = NoDB("./my_database")

# Get a table for your model
users = db.table(User, key_expr="id")

# Create and save records
user = User(id=1, name="Alice Smith", email="alice@example.com", age=30)
users.save(user)

# Fetch records
retrieved_user = users.fetch("1")
print(retrieved_user.name)  # Alice Smith

# Get all records
all_users = users.all()

Secondary Indexing

# Create indices (best to do this before adding records)
age_index = users.index("age")

# Add some users (index will be automatically updated)
users.save(User(id=1, name="Alice", email="alice@example.com", age=30))
users.save(User(id=2, name="Bob", email="bob@example.com", age=25))
users.save(User(id=3, name="Carol", email="carol@example.com", age=30))

# Find all users of a specific age
thirty_year_olds = age_index.get("30")

# If you create an index after records exist, rebuild it:
# age_index.rebuild_index()

Contributing Tips

We welcome contributions! Here's how to get started:

Development Setup

  1. Clone the repository:

    git clone https://github.com/slank/nondb.git
    cd nondb
    
  2. Install development dependencies:

    pip install -e ".[dev]"
    
  3. Run tests:

    python -m unittest discover tests/ -v
    

Code Style

  • We use Black for code formatting
  • Type hints are required for all public APIs
  • Follow PEP 8 naming conventions
  • Write docstrings for all public methods

Testing

  • Add tests for all new features
  • Maintain test coverage above 90%
  • Tests are located in the tests/ directory
  • Use descriptive test names and docstrings

Submitting Changes

  1. Create a feature branch:

    git checkout -b feature/your-feature-name
    
  2. Make your changes with tests

  3. Run the test suite:

    python -m unittest discover tests/ -v
    
  4. Format your code:

    black src/ tests/
    
  5. Submit a pull request with:

    • Clear description of changes
    • Tests for new functionality
    • Updated documentation if needed

Areas for Contribution

  • Performance improvements: Optimize file I/O operations
  • Query capabilities: Enhanced filtering and search
  • Documentation: More examples and tutorials
  • Error handling: Better error messages and recovery
  • Concurrent access: Thread-safe operations
  • Data migration: Tools for schema evolution

Reporting Issues

When reporting bugs, please include:

  • Python version
  • Nondb version
  • Minimal reproduction case
  • Error messages and stack traces
  • Expected vs actual behavior

License

MIT License - see LICENSE file for details.

Metadata

Release files for nondb 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nondb 0.1.4
File Size Uploaded Provenance
nondb-0.1.4.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for nondb 0.1.4
File Interpreter ABI Platform
nondb-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / nondb-0.1.4.tar.gz

Download URL nondb-0.1.4.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ed792e566fd4acfd9320275a400a34bef60b64920804b318e6b0e02792d744f7
BLAKE2b-256 checksum
How to use checksums
c14d0165e4fcc83dbc285c72f4e200b26d388c0d0ffb70770c0259b2a60e8802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.19

Release files / nondb-0.1.4-py3-none-any.whl

Download URL nondb-0.1.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
10e60beded5a54bba345ec89ddfaa15b92c74b3acc2e1883423e11dc1058d5ed
BLAKE2b-256 checksum
How to use checksums
5d8c42d7a244b869e8b46dc77005db9cfb6db1bf609619cfdf397f552aed193a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.8.19

Security for nondb 0.1.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page