beanis


Namebeanis JSON
Version 0.0.8 PyPI version JSON
download
home_pageNone
SummaryAsynchronous Python ODM for Redis
upload_time2024-06-21 11:31:26
maintainerNone
docs_urlNone
authorNone
requires_python<4.0,>=3.7
licenseNone
keywords redis odm orm pydantic async python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Beanis](https://raw.githubusercontent.com/andreim14/beanis/main/assets/logo/logo-no-background.svg)](https://github.com/andreim14/beanis)

<div align="center">

  <a href="https://pypi.python.org/pypi/beanis">![pypi](https://img.shields.io/pypi/v/beanis)</a>

</div>

## 📢 Work in Progress Disclaimer 📢

**Beanis is currently a work in progress.** While the core functionality is being actively developed, some features may still be in the testing phase. We appreciate your understanding and welcome any feedback or contributions to help us improve the project.

## Overview

[Beanis](https://github.com/andreim14/beanis) is an asynchronous Python object-document mapper (ODM) for Redis, designed to simplify database interactions using data models based on [Pydantic](https://pydantic-docs.helpmanual.io/).

With Beanis, each Redis key is represented by a `Document`, allowing for easy interaction with that key. This includes retrieving, adding, updating, and deleting documents from the key, all while maintaining the simplicity and power of Pydantic models.

Beanis aims to save you time by eliminating boilerplate code, allowing you to focus on the crucial parts of your application.

## Installation

### PIP

```shell
pip install beanis
```

### Poetry

```shell
poetry add beanis
```

## Example

```python
import asyncio
from typing import Optional

from redis import Redis
from pydantic import BaseModel

from beanis import Document, init_beanis


class Category(BaseModel):
    name: str
    description: str


class Product(Document):
    name: str  # You can use normal types just like in pydantic
    description: Optional[str] = None
    price: float
    category: Category  # You can include pydantic models as well


# This is an asynchronous example, so we will access it from an async function
async def example():
    # Beanis uses Redis async client under the hood
    client = Redis(host="localhost", port=6379, db=0, decode_responses=True)

    # Initialize beanis with the Product document class
    await init_beanis(database=client, document_models=[Product])

    chocolate = Category(
        name="Chocolate",
        description="A preparation of roasted and ground cacao seeds.",
    )
    # Beanis documents work just like pydantic models
    tonybar = Product(
        id="unique_magic_id", name="Tony's", price=5.95, category=chocolate
    )
    # And can be inserted into the database
    await tonybar.insert()

    # You can find documents by their unique id
    product = await Product.find("unique_magic_id")
    print(product)


if __name__ == "__main__":
    asyncio.run(example())

```

---

Thanks to the amazing team behind [Beanie](https://github.com/BeanieODM/beanie), Beanis brings similar powerful ODM capabilities to Redis, making it easier than ever to manage your Redis database with Python. Please check them out:

[![Beanie](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/white_bg.svg)](https://github.com/BeanieODM/beanie)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "beanis",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.7",
    "maintainer_email": null,
    "keywords": "redis, odm, orm, pydantic, async, python",
    "author": null,
    "author_email": "Andrei Stefan Bejgu <stefan.bejgu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/41/37/58f5c481ebb15d66f13325511bece75dc254dfd08d34d73677c1e7a5a3b6/beanis-0.0.8.tar.gz",
    "platform": null,
    "description": "[![Beanis](https://raw.githubusercontent.com/andreim14/beanis/main/assets/logo/logo-no-background.svg)](https://github.com/andreim14/beanis)\n\n<div align=\"center\">\n\n  <a href=\"https://pypi.python.org/pypi/beanis\">![pypi](https://img.shields.io/pypi/v/beanis)</a>\n\n</div>\n\n## \ud83d\udce2 Work in Progress Disclaimer \ud83d\udce2\n\n**Beanis is currently a work in progress.** While the core functionality is being actively developed, some features may still be in the testing phase. We appreciate your understanding and welcome any feedback or contributions to help us improve the project.\n\n## Overview\n\n[Beanis](https://github.com/andreim14/beanis) is an asynchronous Python object-document mapper (ODM) for Redis, designed to simplify database interactions using data models based on [Pydantic](https://pydantic-docs.helpmanual.io/).\n\nWith Beanis, each Redis key is represented by a `Document`, allowing for easy interaction with that key. This includes retrieving, adding, updating, and deleting documents from the key, all while maintaining the simplicity and power of Pydantic models.\n\nBeanis aims to save you time by eliminating boilerplate code, allowing you to focus on the crucial parts of your application.\n\n## Installation\n\n### PIP\n\n```shell\npip install beanis\n```\n\n### Poetry\n\n```shell\npoetry add beanis\n```\n\n## Example\n\n```python\nimport asyncio\nfrom typing import Optional\n\nfrom redis import Redis\nfrom pydantic import BaseModel\n\nfrom beanis import Document, init_beanis\n\n\nclass Category(BaseModel):\n    name: str\n    description: str\n\n\nclass Product(Document):\n    name: str  # You can use normal types just like in pydantic\n    description: Optional[str] = None\n    price: float\n    category: Category  # You can include pydantic models as well\n\n\n# This is an asynchronous example, so we will access it from an async function\nasync def example():\n    # Beanis uses Redis async client under the hood\n    client = Redis(host=\"localhost\", port=6379, db=0, decode_responses=True)\n\n    # Initialize beanis with the Product document class\n    await init_beanis(database=client, document_models=[Product])\n\n    chocolate = Category(\n        name=\"Chocolate\",\n        description=\"A preparation of roasted and ground cacao seeds.\",\n    )\n    # Beanis documents work just like pydantic models\n    tonybar = Product(\n        id=\"unique_magic_id\", name=\"Tony's\", price=5.95, category=chocolate\n    )\n    # And can be inserted into the database\n    await tonybar.insert()\n\n    # You can find documents by their unique id\n    product = await Product.find(\"unique_magic_id\")\n    print(product)\n\n\nif __name__ == \"__main__\":\n    asyncio.run(example())\n\n```\n\n---\n\nThanks to the amazing team behind [Beanie](https://github.com/BeanieODM/beanie), Beanis brings similar powerful ODM capabilities to Redis, making it easier than ever to manage your Redis database with Python. Please check them out:\n\n[![Beanie](https://raw.githubusercontent.com/roman-right/beanie/main/assets/logo/white_bg.svg)](https://github.com/BeanieODM/beanie)\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Asynchronous Python ODM for Redis",
    "version": "0.0.8",
    "project_urls": {
        "homepage": "https://github.com/andreim14/beanis",
        "repository": "https://github.com/andreim14/beanis"
    },
    "split_keywords": [
        "redis",
        " odm",
        " orm",
        " pydantic",
        " async",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "988309776e19ac4c415dcbcbfdcb71e2f09c5d872999f3040025106f0d31d814",
                "md5": "6a09b2c98174f43e46774db8b331d2e2",
                "sha256": "d14962f9ae9e3a81ccb6d038fe53f26048fc19219afd77b9b78d6ca8e57b7067"
            },
            "downloads": -1,
            "filename": "beanis-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6a09b2c98174f43e46774db8b331d2e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.7",
            "size": 56304,
            "upload_time": "2024-06-21T11:31:23",
            "upload_time_iso_8601": "2024-06-21T11:31:23.149245Z",
            "url": "https://files.pythonhosted.org/packages/98/83/09776e19ac4c415dcbcbfdcb71e2f09c5d872999f3040025106f0d31d814/beanis-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "413758f5c481ebb15d66f13325511bece75dc254dfd08d34d73677c1e7a5a3b6",
                "md5": "212bc5a6eeb41a2711fd3ea6ca76ff65",
                "sha256": "2badb0d9d3243b1901bf9f9f453ed4d14f6806b26c8804dd44a567fed3125f59"
            },
            "downloads": -1,
            "filename": "beanis-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "212bc5a6eeb41a2711fd3ea6ca76ff65",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.7",
            "size": 38851,
            "upload_time": "2024-06-21T11:31:26",
            "upload_time_iso_8601": "2024-06-21T11:31:26.471002Z",
            "url": "https://files.pythonhosted.org/packages/41/37/58f5c481ebb15d66f13325511bece75dc254dfd08d34d73677c1e7a5a3b6/beanis-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-21 11:31:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "andreim14",
    "github_project": "beanis",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "beanis"
}
        
Elapsed time: 0.35977s