{"id":35209977,"url":"https://github.com/dbzero-software/dbzero","last_synced_at":"2026-06-16T08:00:30.952Z","repository":{"id":329827796,"uuid":"775860531","full_name":"dbzero-software/dbzero","owner":"dbzero-software","description":"DISTIC (Durable, Infinite, Shared, Transactional, Isolated, Composable) storage system for Python 3.x offering flexibility of a memory with durability of a database.","archived":false,"fork":false,"pushed_at":"2026-06-13T11:43:23.000Z","size":16463,"stargazers_count":56,"open_issues_count":37,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-13T13:18:21.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dbzero.io","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbzero-software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":"CLA.md"}},"created_at":"2024-03-22T07:29:44.000Z","updated_at":"2026-06-03T06:44:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/dbzero-software/dbzero","commit_stats":null,"previous_names":["dbzero-software/dbzero"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/dbzero-software/dbzero","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbzero-software%2Fdbzero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbzero-software%2Fdbzero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbzero-software%2Fdbzero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbzero-software%2Fdbzero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbzero-software","download_url":"https://codeload.github.com/dbzero-software/dbzero/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbzero-software%2Fdbzero/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34396429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-29T17:30:16.108Z","updated_at":"2026-06-16T08:00:30.897Z","avatar_url":"https://github.com/dbzero-software.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"\u003cpicture align=\"center\"\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://dbzero.io/images/white-01.svg\"\u003e\n  \u003cimg alt=\"Dbzero logo\" src=\"https://dbzero.io/images/dbzero-logo.png\"\u003e\n\u003c/picture\u003e\n\n\n**A state management system for Python 3.x that unifies your application's business logic, data persistence, and caching into a single, efficient layer.**\n\n[![License: LGPL 2.1](https://img.shields.io/badge/License-LGPL%202.1-blue.svg)](https://www.gnu.org/licenses/lgpl-2.1)\n\n\u003e \"If we had infinite memory in our laptop, we'd have no need for clumsy databases. Instead, we could just use our objects whenever we liked.\"\n\u003e \n\u003e — Harry Percival and Bob Gregory, *Architecture Patterns with Python*\n\n## Overview\n\n**dbzero** lets you code as if you have infinite memory. Inspired by a thought experiment from *Architecture Patterns with Python* by Harry Percival and Bob Gregory, dbzero handles the complexities of data management in the background while you work with simple Python objects.\n\ndbzero implements the **DISTIC memory** model:\n- **D**urable - Data persists across application restarts\n- **I**nfinite - Work with data as if memory constraints don't exist (e.g. create lists, dicts or sets with billions of elements)\n- **S**hared - Multiple processes can access and share the same data\n- **T**ransactional - Transaction support for data integrity\n- **I**solated - Reads performed against a consistent point-in-time snapshot\n- **C**omposable - Plug in multiple prefixes (memory partitions) on demand and access other apps’ data by simply attaching their prefix.\n\nWith dbzero, you don’t need separate pieces like a database, ORM, or cache layer. Your app becomes easier to build and it runs faster, because there are no roundtrips to a database, memory is used better, and you can shape your data to fit your problem.\n\n## Key Platform Features\n\n**dbzero** provides the reliability of a traditional database system with modern capabilities and extra features on top.\n\n- **Persistence**: Application objects (classes and common structures like `list`, `dict`, `set`, etc.) are automatically persisted (e.g. to a local or network-attached file)\n- **Efficient caching**: Only the data actually accessed is retrieved and cached. For example, if a list has 1 million elements but only 10 are accessed, only those 10 are loaded.\n- **Constrained memory usage**: You can define memory limits for the process to control RAM consumption.\n- **Serializable consistency**: Data changes can be read immediately, maintaining a consistent view.\n- **Transactions**: Make atomic, exception-safe changes using the `with dbzero.atomic():` context manager.\n- **Snapshots \u0026 Time Travel**: Query data as it existed at a specific point in the past. This enables tracking of data changes and simplify auditing.\n- **Tags**: Tag objects and use tags to filter or retrieve data.\n- **Indexing**: Define lightweight, imperative indexes that can be dynamically created and updated.\n- **Data composability**: Combine data from different apps, processes, or servers and access it through a unified interface - i.e. your application’s objects, methods and functions.\n- **UUID support**: All objects are automatically assigned a universally unique identifier, allowing to always reference them directly.\n- **Custom data models** - Unlike traditional databases, dbzero allows you to define custom data structures to match your domain's needs.\n\n## Requirements\n\n- **Python**: 3.9+\n- **Operating Systems**: Linux, macOS, Windows\n- **Storage**: Local filesystem or network-attached storage\n- **Memory**: Varies by workload; active working set should fit in RAM for best performance\n\n## Quick Start\n\n### Installation\n\n```bash\npip install dbzero\n```\n\n### Simple Example\n\nThe guiding philosophy behind **dbzero** is *invisibility*—it stays out of your way as much as possible. In most cases, unless you're using advanced features, you won’t even notice it’s there. No schema definitions, no explicit save calls, no ORM configuration. You just write regular Python code, as you always have. See the complete working example below:\n\n```python\nimport dbzero as db0\n\n@db0.memo(singleton=True)\nclass GreeterAppRoot:\n    def __init__(self, greeting, persons):\n        self.greeting = greeting\n        self.persons = persons\n        self.counter = 0\n\n    def greet(self):\n        print(f\"{self.greeting}{''.join(f', {person}' for person in self.persons)}!\")\n        self.counter += 1\n\nif __name__ == \"__main__\":\n    # Initialize dbzero\n    db0.init(\"./app-data\", prefix=\"main\")\n    # Initialize the application's root object\n    root = GreeterAppRoot(\"Hello\", [\"Michael\", \"Jennifer\"])\n    root.greet() # Output: Hello, Michael, Jennifer!\n    print(f\"Greeted {root.counter} times.\")\n```\n\nThe application state is persisted automatically; the same data will be available the next time the app starts. All objects are automatically managed by dbzero and there's no need for explicit conversions, fetching, or saving — dbzero handles persistence transparently for the entire object graph.\n\n## Core Concepts\n\n### Memo Classes\n\nTransform any Python class into a persistent, automatically managed object by applying the `@db0.memo` decorator:\n\n```python\nimport dbzero as db0\n\n@db0.memo\nclass Person:\n    def __init__(self, name: str, age: int):\n        self.name = name\n        self.age = age\n\n# Instantiation works just like regular Python\nperson = Person(\"Alice\", 30)\n\n# Attributes can be changed dynamically\nperson.age += 1\nperson.address = \"123 Main St\"  # Add new attributes on the fly\n```\n\n### Collections\n\ndbzero provides persistent versions of Python's built-in collections:\n\n```python\nfrom datetime import date\n\nperson = Person(\"John\", 25)\n\n# Assign persistent collections to memo object\nperson.appointment_dates = {date(2026, 1, 12), date(2026, 1, 13), date(2026, 1, 14)}\n\nperson.skills = [\"Python\", \"C++\", \"Docker\"]\n\nperson.contact_info = {\n    \"email\": \"john@example.com\",\n    \"phone\": \"+1-555-0100\",\n    \"linkedin\": \"linkedin.com/in/john\"\n}\n\n# Use them as usual\ndate(2026, 1, 13) in person.appointment_dates # True\n\nperson.skills.append(\"Kubernetes\") \nprint(person.skills) # Output: ['Python', 'C++', 'Docker', 'Kubernetes']\n\nperson.contact_info[\"github\"] = \"github.com/john\"\nperson.contact_info[\"email\"] # \"john@example.com\"\n\n```\n\nAll standard operations are supported, and changes are automatically persisted.\n\n### Queries and Tags\n\nFind objects using tag-based queries and flexible logic operators:\n\n```python\n# Create and tag objects\nperson = Person(\"Susan\", 31)\ndb0.tags(person).add(\"employee\", \"manager\")\n\nperson = Person(\"Michael\", 29)\ndb0.tags(person).add(\"employee\", \"developer\")\n\n# Find every Person by type\nresult = db0.find(Person)\n\n# Combine type and tags (AND logic) to find employees\nemployees = db0.find(Person, \"employee\")\n\n# OR logic using a list to find managers and developers\nstaff = db0.find([\"manager\", \"developer\"])\n\n# NOT logic using db0.no() to find employees wich aren't managers\nnon_managers = db0.find(\"employee\", db0.no(\"manager\"))\n```\n\n### Snapshots and Time Travel\n\nCreate isolated views of your data at any point in time:\n\n```python\nperson = Person(\"John\", 25)\nperson.balance = 1500\n# Keep the current state \nstate = db0.get_state_num()\n# Commit changes explicitely to advance the state immediately\ndb0.commit()\n\n# Change the balance\nperson.balance -= 300\ndb0.commit()\n\nprint(f\"{person.name} balance: {person.balance}\") # John balance: 1200\n# Open snapshot view with past state number\nwith db0.snapshot(state) as snap:\n    past_person = db0.fetch(db0.uuid(person))\n    print(f\"{past_person.name} balance: {past_person.balance}\") # John balance: 1500\n```\n\n### Prefixes (Data Partitioning)\n\nOrganize data into independent, isolated partitions:\n\n```python\n@db0.memo(singleton=True, prefix=\"/my-org/my-app/settings\")\nclass AppSettings:\n    def __init__(self, theme: str):\n        self.theme = theme\n\n@db0.memo(prefix=\"/my-org/my-app/data\")\nclass Note:\n    def __init__(self, content: str):\n        self.content = content\n\nsettings = AppSettings(theme=\"dark\") # Data goes to \"settings.db0\"\nnote = Note(\"Hello dbzero!\")         # Data goes to \"data.db0\"\n```\n\n### Indexes\n\nIndex your data for fast range queries and sorting:\n\n```python\nfrom datetime import datetime\n\n@db0.memo()\nclass Event:\n    def __init__(self, event_id: int, occured: datetime):\n        self.event_id = event_id\n        self.occured = occured\n\nevents = [\n    Event(100, datetime(2026, 1, 28)),\n    Event(101, datetime(2026, 1, 30)),\n    Event(102, datetime(2026, 1, 29)),\n    Event(103, datetime(2026, 2, 1)),\n]\n\n# Create an index\nevent_index = db0.index()\n# Populate with objects\nfor event in events:\n    event_index.add(event.occured, event)\n\n# Query events from January 2026\nquery = event_index.select(datetime(2026, 1, 1), datetime(2026, 1, 31))\n# Sort ascending by date of occurance\nquery_sorted = event_index.sort(query)\nprint([event.event_id for event in query_sorted]) # Output: [100, 102, 101]\n\n```\n\n## Scalability\n\ndbzero provides tools to build scalable applications:\n\n- **Data Partitioning** - Split data across independent partitions (prefixes) to distribute workload\n- **Distributed Transactions** - Coordinate transactions across multiple partitions for data consistency\n- **Multi-Process Support** - Multiple processes can work with shared or separate data simultaneously, enabling horizontal scaling\n\nThese features give you the flexibility to design distributed architectures that fit your needs.\n\n\n## Use Cases\n\nOur experience has proven that **dbzero** fits many real-life use cases, which include:\n\n- **Web Applications** - Unified state management for backend services\n- **Data Processing Pipelines** - Efficient and simple data preparation\n- **Event-Driven Systems** - Capturing data changes and time travel for auditing\n- **AI Applications** - Simplified state management for AI agents and workflows\n- **Something Else?** - Built something cool with dbzero? We'd love to see what you're working on—share it on our [Discord server](https://discord.gg/9Wn8TAYEPu)!\n\n## Why dbzero?\n\nThe short answer is illustrated by diagram below:\n\n### Traditional Stack\n```\nApplication Code\n    ↓\nORM Layer\n    ↓\nCaching Layer\n    ↓\nDatabase Layer\n    ↓\nStorage\n```\n\n### With dbzero\n```\nApplication Code + dbzero\n    ↓\nStorage\n```\n\nBy eliminating intermediate layers, dbzero reduces complexity, improves performance, and accelerates development—all while providing the reliability and features you expect from a regular database system.\n\n## Documentation\n\nCheck our docs to learn more: **[docs.dbzero.io](https://docs.dbzero.io)**\n\nThere you can find:\n- Guides\n- Tutorials\n- Performance tips\n- API Reference\n\n## License\n\nThis project is licensed under the GNU Lesser General Public License v2.1 (LGPL 2.1). See [LICENSE](./LICENSE) for the full text.\n\n- This library can be linked with proprietary software.\n- Modifications to the library itself must be released under LGPL 2.1.\n- Redistributions must preserve copyright and license notices and provide source.\n\nFor attribution details, see [NOTICE](./NOTICE).\n\n## Support\n\n- **Documentation**: [docs.dbzero.io](https://docs.dbzero.io)\n- **Email**: info@dbzero.io\n- **Issues**: https://github.com/dbzero-software/dbzero/issues\n\n## Feedback\n\nWe'd love to hear how you're using dbzero and what features you'd like to see! Your input helps us make dbzero better for everyone.\n\nThe best way to share your thoughts is through our **Discord server**: [Join us on Discord](https://discord.gg/9Wn8TAYEPu)\n\n## Commercial Support\n\nNeed help building large-scale solutions with dbzero?\n\nWe offer:\n- Tools for data export and manipulation\n- Tools for hosting rich UI applications on top of your existing dbzero codebase\n- System integrations\n- Expert consulting and architectural reviews\n- Performance tuning\n\nContact us at: **info@dbzero.io**\n\n---\n\n**Start coding as if you have infinite memory. Let dbzero handle the rest.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbzero-software%2Fdbzero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbzero-software%2Fdbzero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbzero-software%2Fdbzero/lists"}