# 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/5d/92/fba1d54fc753c51e4c076048229f49d7ff2ad81a14925070c9c8ca80efaa/creyPY-1.2.3.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": "1.2.3",
"project_urls": {
"Homepage": "https://github.com/creyD/creyPY"
},
"split_keywords": [
"creypy",
" python",
" fastapi",
" shortcuts",
" snippets",
" utils",
" personal library"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "50a52e5b5fe3f62b60bd8846c0f528b9742531690263bb8375e36c2e7550d450",
"md5": "32c6aaaf0f03b0f9c6f6d66ff87aaf56",
"sha256": "779463e3e16ea481331f9be16842a8d2a39a4298d3e912fefe38cd8af6203168"
},
"downloads": -1,
"filename": "creyPY-1.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "32c6aaaf0f03b0f9c6f6d66ff87aaf56",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 16022,
"upload_time": "2024-05-13T09:23:12",
"upload_time_iso_8601": "2024-05-13T09:23:12.421073Z",
"url": "https://files.pythonhosted.org/packages/50/a5/2e5b5fe3f62b60bd8846c0f528b9742531690263bb8375e36c2e7550d450/creyPY-1.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5d92fba1d54fc753c51e4c076048229f49d7ff2ad81a14925070c9c8ca80efaa",
"md5": "72ffaeb279bbe2ce240a1a13fc34255e",
"sha256": "29994133621e8d8ccf9b8acda4451089d13283bb12b73e2a1696e203aad4047d"
},
"downloads": -1,
"filename": "creyPY-1.2.3.tar.gz",
"has_sig": false,
"md5_digest": "72ffaeb279bbe2ce240a1a13fc34255e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 14480,
"upload_time": "2024-05-13T09:23:14",
"upload_time_iso_8601": "2024-05-13T09:23:14.052444Z",
"url": "https://files.pythonhosted.org/packages/5d/92/fba1d54fc753c51e4c076048229f49d7ff2ad81a14925070c9c8ca80efaa/creyPY-1.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-13 09:23:14",
"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"
}