peewee-enum-field


Namepeewee-enum-field JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA custom EnumField for Peewee ORM to handle Python Enum types.
upload_time2024-09-15 10:56:22
maintainerNone
docs_urlNone
authorSebastian Kucharzyk
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # peewee-enum-field

A custom field for [Peewee](http://docs.peewee-orm.com/en/latest/), a small, expressive ORM, that allows for the easy integration of Python Enums in Peewee models.

## Overview

`peewee-enum-field` provides a convenient way to store Python Enum types in a Peewee database. This custom field stores the name of an Enum member as a string in the database and handles automatic conversion between the Enum type and the string representation when reading or writing to the database.

## Installation

To install `peewee-enum-field`, you can use pip:

```bash
pip install peewee-enum-field
```

## Usage

```python
from enum import Enum

class Color(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3
```

Then, use EnumField in your Peewee model:

```python
import peewee
from peewee_enum_field import EnumField

class MyModel(peewee.Model):
    color = EnumField(Color)
```

You can now assign Enum members to the field, filter, etc:

```python
instance = MyModel.create(color=Color.RED)
instance = MyModel.get(Color.color == Color.RED)
```

The field automatically handles conversion to and from the Enum type:

```python
assert instance.color == Color.RED
```


## Features
- Easy integration with Peewee models.
- Stores the name of the Enum member in the database for readability.
- Automatically converts to and from the Python Enum type.

## Requirements
- Python 3.6+
- Peewee

## License
peewee-enum-field is released under the [MIT License](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "peewee-enum-field",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Sebastian Kucharzyk",
    "author_email": "kucharzyk.sebastian@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7e/dc/003bd673d0cd791925c28c6db310575a43a048a2cacfc4755e2582f993bc/peewee_enum_field-0.2.0.tar.gz",
    "platform": null,
    "description": "# peewee-enum-field\n\nA custom field for [Peewee](http://docs.peewee-orm.com/en/latest/), a small, expressive ORM, that allows for the easy integration of Python Enums in Peewee models.\n\n## Overview\n\n`peewee-enum-field` provides a convenient way to store Python Enum types in a Peewee database. This custom field stores the name of an Enum member as a string in the database and handles automatic conversion between the Enum type and the string representation when reading or writing to the database.\n\n## Installation\n\nTo install `peewee-enum-field`, you can use pip:\n\n```bash\npip install peewee-enum-field\n```\n\n## Usage\n\n```python\nfrom enum import Enum\n\nclass Color(Enum):\n    RED = 1\n    GREEN = 2\n    BLUE = 3\n```\n\nThen, use EnumField in your Peewee model:\n\n```python\nimport peewee\nfrom peewee_enum_field import EnumField\n\nclass MyModel(peewee.Model):\n    color = EnumField(Color)\n```\n\nYou can now assign Enum members to the field, filter, etc:\n\n```python\ninstance = MyModel.create(color=Color.RED)\ninstance = MyModel.get(Color.color == Color.RED)\n```\n\nThe field automatically handles conversion to and from the Enum type:\n\n```python\nassert instance.color == Color.RED\n```\n\n\n## Features\n- Easy integration with Peewee models.\n- Stores the name of the Enum member in the database for readability.\n- Automatically converts to and from the Python Enum type.\n\n## Requirements\n- Python 3.6+\n- Peewee\n\n## License\npeewee-enum-field is released under the [MIT License](LICENSE).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A custom EnumField for Peewee ORM to handle Python Enum types.",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c0200468507590d827a21e6f3209d72485f2110c1024adf3463c4ff41f64332",
                "md5": "ab3f6192fdececb39b2a22ac55e53ccd",
                "sha256": "28bb3aaeab9bbe639209ed8dd8673c60e04ece199eb8c6962205df6a3a28e24a"
            },
            "downloads": -1,
            "filename": "peewee_enum_field-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ab3f6192fdececb39b2a22ac55e53ccd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 3394,
            "upload_time": "2024-09-15T10:56:21",
            "upload_time_iso_8601": "2024-09-15T10:56:21.341076Z",
            "url": "https://files.pythonhosted.org/packages/6c/02/00468507590d827a21e6f3209d72485f2110c1024adf3463c4ff41f64332/peewee_enum_field-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7edc003bd673d0cd791925c28c6db310575a43a048a2cacfc4755e2582f993bc",
                "md5": "99c95fe1817de8369cc87ba9301bd15b",
                "sha256": "13b4e453cd35c3e0cf5df991340c4355d614056d2a1abc00f548a37a3bb62504"
            },
            "downloads": -1,
            "filename": "peewee_enum_field-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "99c95fe1817de8369cc87ba9301bd15b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 3017,
            "upload_time": "2024-09-15T10:56:22",
            "upload_time_iso_8601": "2024-09-15T10:56:22.869286Z",
            "url": "https://files.pythonhosted.org/packages/7e/dc/003bd673d0cd791925c28c6db310575a43a048a2cacfc4755e2582f993bc/peewee_enum_field-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-15 10:56:22",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "peewee-enum-field"
}
        
Elapsed time: 0.30944s