# creyPY
My collection of Python and FastAPI shortcuts etc.
## Installation
```bash
pip install creyPY -U
```
## Versioning
This library uses [Semantic Versioning](https://semver.org/).
## FastAPI
This library installes fastapi and pydantic, as well as sqlalchemy for you. It also provides a sqlalchemy base class and companion pydantic schemas. Also there are some helper functions for FastAPI in `creyPY.fastapi.app` like `generate_unique_id` to generate unique operation IDs for the OpenAPI schema to work with code generators.
### Database connection
The `creyPY.fastapi.db` module provides a `Session` class that can be used as a context manager to connect to a database. It exposes the `SQLALCHEMY_DATABASE_URL` variable for you to use. It uses the following environment variables:
- `POSTGRES_HOST`: The host of the database
- `POSTGRES_PORT`: The port of the database
- `POSTGRES_USER`: The user of the database
- `POSTGRES_PASSWORD`: The password of the database
- `POSTGRES_DB`: The database name
Currently only PostgreSQL is supported. It creates a sync session, it is planned to add async support in the future. You can use this like this:
```python
from creyPY.fastapi.db.session import get_db
async def test_endpoint(
db: Session = Depends(get_db),
) -> Any:
pass
```
## Constants
The constants module contains a few enums that I use in my projects. The best way to understand this library is to look at the code (it's not that much). However for simplicity, here is a brief overview:
- LanguageEnum: Contains all languages according to ISO 639
- CountryEnum: Contains all countries according to ISO 3166
- CurrencyEnum: Contains all accepted stripe currencies (Commented out are the Zero-decimal currencies, to avoid custom implementation)
- StripeStatus: Contains all stripe payment statuses
- GroupMode: Contains time group modes (e.g. day, week, month, year)
### Usage example
```python
from creyPY.const import LanguageEnum
print(LanguageEnum.EN) # Output: LanguageEnum.EN
print(LanguageEnum.EN.value) # Output: English
```
## TODO
- Add async support for database connection
- Add version without postgresql dependency
Raw data
{
"_id": null,
"home_page": "https://github.com/creyD/creyPY",
"name": "creyPY",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "creyPY, Python, FastAPI, shortcuts, snippets, utils, personal library",
"author": "Conrad Gro\u00dfer",
"author_email": "conrad@noah.tech",
"download_url": "https://files.pythonhosted.org/packages/31/dd/306ad2c698dc33a5447f36f46c0a738c7004466aa6dda6dd05a89e11e711/creypy-2.0.2.tar.gz",
"platform": "any",
"description": "# creyPY\n\nMy collection of Python and FastAPI shortcuts etc.\n\n## Installation\n\n```bash\npip install creyPY -U\n```\n\n## Versioning\n\nThis library uses [Semantic Versioning](https://semver.org/).\n\n## FastAPI\n\nThis library installes fastapi and pydantic, as well as sqlalchemy for you. It also provides a sqlalchemy base class and companion pydantic schemas. Also there are some helper functions for FastAPI in `creyPY.fastapi.app` like `generate_unique_id` to generate unique operation IDs for the OpenAPI schema to work with code generators.\n\n### Database connection\n\nThe `creyPY.fastapi.db` module provides a `Session` class that can be used as a context manager to connect to a database. It exposes the `SQLALCHEMY_DATABASE_URL` variable for you to use. It uses the following environment variables:\n\n- `POSTGRES_HOST`: The host of the database\n- `POSTGRES_PORT`: The port of the database\n- `POSTGRES_USER`: The user of the database\n- `POSTGRES_PASSWORD`: The password of the database\n- `POSTGRES_DB`: The database name\n\nCurrently only PostgreSQL is supported. It creates a sync session, it is planned to add async support in the future. You can use this like this:\n\n```python\nfrom creyPY.fastapi.db.session import get_db\n\nasync def test_endpoint(\n db: Session = Depends(get_db),\n) -> Any:\n pass\n```\n\n## Constants\n\nThe constants module contains a few enums that I use in my projects. The best way to understand this library is to look at the code (it's not that much). However for simplicity, here is a brief overview:\n\n- LanguageEnum: Contains all languages according to ISO 639\n- CountryEnum: Contains all countries according to ISO 3166\n- CurrencyEnum: Contains all accepted stripe currencies (Commented out are the Zero-decimal currencies, to avoid custom implementation)\n- StripeStatus: Contains all stripe payment statuses\n- GroupMode: Contains time group modes (e.g. day, week, month, year)\n\n### Usage example\n\n```python\nfrom creyPY.const import LanguageEnum\n\nprint(LanguageEnum.EN) # Output: LanguageEnum.EN\nprint(LanguageEnum.EN.value) # Output: English\n``` \n\n## TODO\n\n- Add async support for database connection\n- Add version without postgresql dependency\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Collection of my Python and FastAPI shortcuts, snippets etc.",
"version": "2.0.2",
"project_urls": {
"Homepage": "https://github.com/creyD/creyPY"
},
"split_keywords": [
"creypy",
" python",
" fastapi",
" shortcuts",
" snippets",
" utils",
" personal library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7eed0889748331086c1f90516345ec6460324a9a992a786cfe9136e9b5b0155f",
"md5": "360986079b2fed02f387c73fea8cff25",
"sha256": "caa547307b53e77defb0a5d98caff300d34c24e94e1a34d8ffef24249e9fbf65"
},
"downloads": -1,
"filename": "creyPY-2.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "360986079b2fed02f387c73fea8cff25",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 16615,
"upload_time": "2024-11-05T10:56:35",
"upload_time_iso_8601": "2024-11-05T10:56:35.320964Z",
"url": "https://files.pythonhosted.org/packages/7e/ed/0889748331086c1f90516345ec6460324a9a992a786cfe9136e9b5b0155f/creyPY-2.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "31dd306ad2c698dc33a5447f36f46c0a738c7004466aa6dda6dd05a89e11e711",
"md5": "5d85699d79c093b28ac4b4415d5a1d7b",
"sha256": "225e0dcc424a8c38f1d85158abea7b86d52c14acd04047d750013f8430cbc99d"
},
"downloads": -1,
"filename": "creypy-2.0.2.tar.gz",
"has_sig": false,
"md5_digest": "5d85699d79c093b28ac4b4415d5a1d7b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 15106,
"upload_time": "2024-11-05T10:56:36",
"upload_time_iso_8601": "2024-11-05T10:56:36.616858Z",
"url": "https://files.pythonhosted.org/packages/31/dd/306ad2c698dc33a5447f36f46c0a738c7004466aa6dda6dd05a89e11e711/creypy-2.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-05 10:56:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "creyD",
"github_project": "creyPY",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "creypy"
}