Collection of my Python and FastAPI shortcuts, snippets etc.
Project description
creyPY
My collection of Python and FastAPI shortcuts etc.
Installation
pip install creyPY -U
Versioning
This library uses Semantic Versioning.
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 databasePOSTGRES_PORT
: The port of the databasePOSTGRES_USER
: The user of the databasePOSTGRES_PASSWORD
: The password of the databasePOSTGRES_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:
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
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file creypy-2.0.2.tar.gz
.
File metadata
- Download URL: creypy-2.0.2.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 225e0dcc424a8c38f1d85158abea7b86d52c14acd04047d750013f8430cbc99d |
|
MD5 | 5d85699d79c093b28ac4b4415d5a1d7b |
|
BLAKE2b-256 | 31dd306ad2c698dc33a5447f36f46c0a738c7004466aa6dda6dd05a89e11e711 |
Provenance
The following attestation bundles were made for creypy-2.0.2.tar.gz
:
Publisher:
ci.yml
on creyD/creyPY
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
creypy-2.0.2.tar.gz
- Subject digest:
225e0dcc424a8c38f1d85158abea7b86d52c14acd04047d750013f8430cbc99d
- Sigstore transparency entry: 146709641
- Sigstore integration time:
- Predicate type:
File details
Details for the file creyPY-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: creyPY-2.0.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | caa547307b53e77defb0a5d98caff300d34c24e94e1a34d8ffef24249e9fbf65 |
|
MD5 | 360986079b2fed02f387c73fea8cff25 |
|
BLAKE2b-256 | 7eed0889748331086c1f90516345ec6460324a9a992a786cfe9136e9b5b0155f |
Provenance
The following attestation bundles were made for creyPY-2.0.2-py3-none-any.whl
:
Publisher:
ci.yml
on creyD/creyPY
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
creypy-2.0.2-py3-none-any.whl
- Subject digest:
caa547307b53e77defb0a5d98caff300d34c24e94e1a34d8ffef24249e9fbf65
- Sigstore transparency entry: 146709646
- Sigstore integration time:
- Predicate type: