masonite-fixtures


Namemasonite-fixtures JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/JarriqTheTechie/masonite-fixtures
SummaryPackage provides utilities for managing fixture data python applications. It offers a convenient way to populate database tables with predefined data.
upload_time2024-03-06 18:34:37
maintainer
docs_urlNone
authorJarriq Rolle
requires_python>=3.9
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Masonite Fixtures

The `masonite-fixtures` package provides utilities for managing fixture data python applications. It offers a convenient way to populate database tables with predefined data.

## Installation

You can install `masonite-fixtures` via pip:

```bash
pip install masonite-fixtures
```

## Features

- Initialize fixture data for database tables effortlessly.
- Automatically create database tables based on the schema of the fixture model.
- Populate database tables with data defined in the fixture model using either `get_rows` method or `rows` property.
- Enable query logging for debugging and monitoring database interactions.

## Usage

To use the `masonite-fixtures` package, follow these steps:

1. Import your model class that implements the `FixtureMixin`.
2. Mix the `FixtureMixin` into your model class.
####
That's it. 
3. Optionally, set the `__log_queries__` attribute to `True` to enable query logging.

Example:

```python
from typing import Any
from masoniteorm.models import Model
from masonite_fixtures import FixtureMixin


# Example using get_rows method:
class User(Model, FixtureMixin):
    def get_rows(self) -> list[dict[str, Any]]:
        return [
            {"name": "John", "age": 30},
            {"name": "Alice", "age": 25},
            # Add more rows as needed
        ]
    
# Example using rows attribute:
class User(Model, FixtureMixin):
    rows: list[dict[str, Any]] = [
            {"name": "John", "age": 30},
            {"name": "Alice", "age": 25},
            # Add more rows as needed
        ]    

```
#### Thats it. You can now use the model as you would any other masoniteorm model. 

## Important
Fixture data is semi-permanent. Every time you modify the fixture model file the data in its database is deleted. If you never modify the model file then the data remains in place. Which means you can even store additional data in fixtures. Personally I would avoid doing this. 


## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
```

This README now provides a more thorough description of the features offered by the `masonite-fixtures` package and includes examples demonstrating the usage of both `get_rows` and `rows`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JarriqTheTechie/masonite-fixtures",
    "name": "masonite-fixtures",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "",
    "author": "Jarriq Rolle",
    "author_email": "jrolle@bnbbahamas.com",
    "download_url": "https://files.pythonhosted.org/packages/96/05/0868e23b6f949af2ac5b4c0ad7c910f9bb798470be092639c4d0987a47e4/masonite-fixtures-0.0.2.tar.gz",
    "platform": null,
    "description": "# Masonite Fixtures\r\n\r\nThe `masonite-fixtures` package provides utilities for managing fixture data python applications. It offers a convenient way to populate database tables with predefined data.\r\n\r\n## Installation\r\n\r\nYou can install `masonite-fixtures` via pip:\r\n\r\n```bash\r\npip install masonite-fixtures\r\n```\r\n\r\n## Features\r\n\r\n- Initialize fixture data for database tables effortlessly.\r\n- Automatically create database tables based on the schema of the fixture model.\r\n- Populate database tables with data defined in the fixture model using either `get_rows` method or `rows` property.\r\n- Enable query logging for debugging and monitoring database interactions.\r\n\r\n## Usage\r\n\r\nTo use the `masonite-fixtures` package, follow these steps:\r\n\r\n1. Import your model class that implements the `FixtureMixin`.\r\n2. Mix the `FixtureMixin` into your model class.\r\n####\r\nThat's it. \r\n3. Optionally, set the `__log_queries__` attribute to `True` to enable query logging.\r\n\r\nExample:\r\n\r\n```python\r\nfrom typing import Any\r\nfrom masoniteorm.models import Model\r\nfrom masonite_fixtures import FixtureMixin\r\n\r\n\r\n# Example using get_rows method:\r\nclass User(Model, FixtureMixin):\r\n    def get_rows(self) -> list[dict[str, Any]]:\r\n        return [\r\n            {\"name\": \"John\", \"age\": 30},\r\n            {\"name\": \"Alice\", \"age\": 25},\r\n            # Add more rows as needed\r\n        ]\r\n    \r\n# Example using rows attribute:\r\nclass User(Model, FixtureMixin):\r\n    rows: list[dict[str, Any]] = [\r\n            {\"name\": \"John\", \"age\": 30},\r\n            {\"name\": \"Alice\", \"age\": 25},\r\n            # Add more rows as needed\r\n        ]    \r\n\r\n```\r\n#### Thats it. You can now use the model as you would any other masoniteorm model. \r\n\r\n## Important\r\nFixture data is semi-permanent. Every time you modify the fixture model file the data in its database is deleted. If you never modify the model file then the data remains in place. Which means you can even store additional data in fixtures. Personally I would avoid doing this. \r\n\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n```\r\n\r\nThis README now provides a more thorough description of the features offered by the `masonite-fixtures` package and includes examples demonstrating the usage of both `get_rows` and `rows`.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Package provides utilities for managing fixture data python applications. It offers a convenient way to populate database tables with predefined data.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/JarriqTheTechie/masonite-fixtures"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e204d74e7da5aa966c761d4ec87609aff90eb49d6f7072501989551d57ff8e0a",
                "md5": "144594de23bde36bad3bf2f83998f4a9",
                "sha256": "cbe4ca3ab3f7b64b964ef4a1a0a8460c0d367fa5462b9bb1507352a06868a449"
            },
            "downloads": -1,
            "filename": "masonite_fixtures-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "144594de23bde36bad3bf2f83998f4a9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4180,
            "upload_time": "2024-03-06T18:34:33",
            "upload_time_iso_8601": "2024-03-06T18:34:33.443377Z",
            "url": "https://files.pythonhosted.org/packages/e2/04/d74e7da5aa966c761d4ec87609aff90eb49d6f7072501989551d57ff8e0a/masonite_fixtures-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "96050868e23b6f949af2ac5b4c0ad7c910f9bb798470be092639c4d0987a47e4",
                "md5": "402576fb4d7f0fe499f0d3446e6c61d4",
                "sha256": "25e64dfa8197d06be81eb288bc55c60fa242a181008f977c4147a3f3f95eb162"
            },
            "downloads": -1,
            "filename": "masonite-fixtures-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "402576fb4d7f0fe499f0d3446e6c61d4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 3791,
            "upload_time": "2024-03-06T18:34:37",
            "upload_time_iso_8601": "2024-03-06T18:34:37.550989Z",
            "url": "https://files.pythonhosted.org/packages/96/05/0868e23b6f949af2ac5b4c0ad7c910f9bb798470be092639c4d0987a47e4/masonite-fixtures-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-06 18:34:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JarriqTheTechie",
    "github_project": "masonite-fixtures",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "masonite-fixtures"
}
        
Elapsed time: 0.21099s