zenithdb


Namezenithdb JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/jolovicdev/zenithdb
SummarySQLite-powered document database with MongoDB-like syntax, full-text search, and advanced querying capabilities
upload_time2024-12-14 01:27:44
maintainerNone
docs_urlNone
authorjolovicdev
requires_python>=3.7
licenseNone
keywords database nosql document-store sqlite json document-database
VCS
bugtrack_url
requirements sqlite3
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ZenithDB

SQLite-powered document database with MongoDB-like syntax, full-text search, and advanced querying capabilities.
For complete examples of all features, PLEASE check out [usage.py](usage.py).

## Features

- **Document Storage & Validation**: Store and validate JSON-like documents with nested structures
- **Advanced Querying**: Full-text search, nested field queries, array operations
- **Multiple Query Styles**: Support for both MongoDB-style dict queries and fluent Query builder
- **Indexing**: Single and compound indexes for optimized performance
- **Aggregations**: Group and aggregate data with functions like COUNT, AVG, SUM
- **Bulk Operations**: Efficient batch processing with transaction support
- **Connection Pooling**: Built-in connection pool for concurrent operations
- **Migration Support**: Versioned database migrations with up/down functions

## Installation

```bash
pip install zenithdb
```

## Quick Start

```python
from zenithdb import Database

# Initialize database
db = Database("myapp.db")
users = db.collection("users")

# Add document validation
def age_validator(doc):
    return isinstance(doc.get('age'), int) and doc['age'] >= 0
users.set_validator(age_validator)

# Insert documents
users.insert({
    "name": "John Doe",
    "age": 30,
    "tags": ["premium"],
    "profile": {"city": "New York"}
})

# Query documents
users.find({
    "age": {"$gt": 25},
    "tags": {"$contains": "premium"}
})

# Full-text search
users.find({"*": {"$contains": "John"}})

# Nested updates
users.update(
    {"name": "John Doe"},
    {"$set": {
        "profile.city": "Brooklyn",
        "tags.0": "vip"
    }}
)

# Aggregations
users.aggregate([{
    "group": {
        "field": "profile.city",
        "function": "COUNT",
        "alias": "count"
    }
}])
```

## Collection Management

```python
# List and count collections
db.list_collections()
db.count_collections()

# Drop collections
db.drop_collection("users")
db.drop_all_collections()

# Print collection contents
users.print_collection()
users.count()
```

## Advanced Features

### Indexing
```python
# Create indexes
db.create_index("users", ["email"])
db.create_index("users", ["profile.city", "age"])

# List indexes
db.list_indexes("users")
```

### Bulk Operations
```python
bulk_ops = users.bulk_operations()
with bulk_ops.transaction():
    bulk_ops.bulk_insert("users", [
        {"name": "User1", "age": 31},
        {"name": "User2", "age": 32}
    ])
```

### Migrations
```python
from zenithdb.migrations import MigrationManager

manager = MigrationManager(db)
migration = {
    'version': '001',
    'name': 'add_users',
    'up': lambda: db.collection('users').insert({'admin': True}),
    'down': lambda: db.collection('users').delete({})
}
manager.apply_migration(migration)
```

## Development

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/
pytest tests/test_migrations.py
pytest --cov=zenithdb tests/
```

For complete examples of all features, check out [usage.py](usage.py).
I would not recommend using this as a production database, but it's a fun project to play around with.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jolovicdev/zenithdb",
    "name": "zenithdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "database, nosql, document-store, sqlite, json, document-database",
    "author": "jolovicdev",
    "author_email": "jolovic@pm.me",
    "download_url": "https://files.pythonhosted.org/packages/d9/5a/637876c7eca5ba9ba40ad3fc20bfc758b62af14a8f1bc5e2e9314dd16527/zenithdb-1.0.1.tar.gz",
    "platform": null,
    "description": "# ZenithDB\n\nSQLite-powered document database with MongoDB-like syntax, full-text search, and advanced querying capabilities.\nFor complete examples of all features, PLEASE check out [usage.py](usage.py).\n\n## Features\n\n- **Document Storage & Validation**: Store and validate JSON-like documents with nested structures\n- **Advanced Querying**: Full-text search, nested field queries, array operations\n- **Multiple Query Styles**: Support for both MongoDB-style dict queries and fluent Query builder\n- **Indexing**: Single and compound indexes for optimized performance\n- **Aggregations**: Group and aggregate data with functions like COUNT, AVG, SUM\n- **Bulk Operations**: Efficient batch processing with transaction support\n- **Connection Pooling**: Built-in connection pool for concurrent operations\n- **Migration Support**: Versioned database migrations with up/down functions\n\n## Installation\n\n```bash\npip install zenithdb\n```\n\n## Quick Start\n\n```python\nfrom zenithdb import Database\n\n# Initialize database\ndb = Database(\"myapp.db\")\nusers = db.collection(\"users\")\n\n# Add document validation\ndef age_validator(doc):\n    return isinstance(doc.get('age'), int) and doc['age'] >= 0\nusers.set_validator(age_validator)\n\n# Insert documents\nusers.insert({\n    \"name\": \"John Doe\",\n    \"age\": 30,\n    \"tags\": [\"premium\"],\n    \"profile\": {\"city\": \"New York\"}\n})\n\n# Query documents\nusers.find({\n    \"age\": {\"$gt\": 25},\n    \"tags\": {\"$contains\": \"premium\"}\n})\n\n# Full-text search\nusers.find({\"*\": {\"$contains\": \"John\"}})\n\n# Nested updates\nusers.update(\n    {\"name\": \"John Doe\"},\n    {\"$set\": {\n        \"profile.city\": \"Brooklyn\",\n        \"tags.0\": \"vip\"\n    }}\n)\n\n# Aggregations\nusers.aggregate([{\n    \"group\": {\n        \"field\": \"profile.city\",\n        \"function\": \"COUNT\",\n        \"alias\": \"count\"\n    }\n}])\n```\n\n## Collection Management\n\n```python\n# List and count collections\ndb.list_collections()\ndb.count_collections()\n\n# Drop collections\ndb.drop_collection(\"users\")\ndb.drop_all_collections()\n\n# Print collection contents\nusers.print_collection()\nusers.count()\n```\n\n## Advanced Features\n\n### Indexing\n```python\n# Create indexes\ndb.create_index(\"users\", [\"email\"])\ndb.create_index(\"users\", [\"profile.city\", \"age\"])\n\n# List indexes\ndb.list_indexes(\"users\")\n```\n\n### Bulk Operations\n```python\nbulk_ops = users.bulk_operations()\nwith bulk_ops.transaction():\n    bulk_ops.bulk_insert(\"users\", [\n        {\"name\": \"User1\", \"age\": 31},\n        {\"name\": \"User2\", \"age\": 32}\n    ])\n```\n\n### Migrations\n```python\nfrom zenithdb.migrations import MigrationManager\n\nmanager = MigrationManager(db)\nmigration = {\n    'version': '001',\n    'name': 'add_users',\n    'up': lambda: db.collection('users').insert({'admin': True}),\n    'down': lambda: db.collection('users').delete({})\n}\nmanager.apply_migration(migration)\n```\n\n## Development\n\n```bash\n# Install development dependencies\npip install -e \".[dev]\"\n\n# Run tests\npytest tests/\npytest tests/test_migrations.py\npytest --cov=zenithdb tests/\n```\n\nFor complete examples of all features, check out [usage.py](usage.py).\nI would not recommend using this as a production database, but it's a fun project to play around with.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "SQLite-powered document database with MongoDB-like syntax, full-text search, and advanced querying capabilities",
    "version": "1.0.1",
    "project_urls": {
        "Bug Reports": "https://github.com/jolovicdev/zenithdb/issues",
        "Documentation": "https://github.com/jolovicdev/zenithdb/blob/master/README.md",
        "Homepage": "https://github.com/jolovicdev/zenithdb",
        "Source": "https://github.com/jolovicdev/zenithdb"
    },
    "split_keywords": [
        "database",
        " nosql",
        " document-store",
        " sqlite",
        " json",
        " document-database"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e33a663f8678a4df98e8ef6d49d3e991ed34b9900e38d5e2db65dcf2d485cced",
                "md5": "3d4898aa396df2868d1188a9f2cced5f",
                "sha256": "be7118d9a74843a7f4cfd3ddc8920e8c8ec246024450103038a12e0cb45f73c6"
            },
            "downloads": -1,
            "filename": "zenithdb-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d4898aa396df2868d1188a9f2cced5f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 28191,
            "upload_time": "2024-12-14T01:27:41",
            "upload_time_iso_8601": "2024-12-14T01:27:41.279599Z",
            "url": "https://files.pythonhosted.org/packages/e3/3a/663f8678a4df98e8ef6d49d3e991ed34b9900e38d5e2db65dcf2d485cced/zenithdb-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d95a637876c7eca5ba9ba40ad3fc20bfc758b62af14a8f1bc5e2e9314dd16527",
                "md5": "024e450adec695f0d939d557a7f4d2e4",
                "sha256": "cb20ea167bd0c32eb2ee55386d689340f6bc568479c533ea15cff77c2ae611aa"
            },
            "downloads": -1,
            "filename": "zenithdb-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "024e450adec695f0d939d557a7f4d2e4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 23895,
            "upload_time": "2024-12-14T01:27:44",
            "upload_time_iso_8601": "2024-12-14T01:27:44.739829Z",
            "url": "https://files.pythonhosted.org/packages/d9/5a/637876c7eca5ba9ba40ad3fc20bfc758b62af14a8f1bc5e2e9314dd16527/zenithdb-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-14 01:27:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jolovicdev",
    "github_project": "zenithdb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "sqlite3",
            "specs": []
        }
    ],
    "lcname": "zenithdb"
}
        
Elapsed time: 0.37201s