Skip to main content

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 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:

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

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

creypy-3.1.0rc59.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

creypy-3.1.0rc59-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file creypy-3.1.0rc59.tar.gz.

File metadata

  • Download URL: creypy-3.1.0rc59.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for creypy-3.1.0rc59.tar.gz
Algorithm Hash digest
SHA256 4beeb4b2d24e5fc707f0484999ccb247d8ed33876aca5bbaac3e91124322482d
MD5 9ca885da71f173a4ea704f7f7b4ad9bc
BLAKE2b-256 3b4620d04ae406358abed47bb36eb75263276f97eac9c7cbe989114f01382b1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for creypy-3.1.0rc59.tar.gz:

Publisher: ci.yml on creyD/creyPY

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file creypy-3.1.0rc59-py3-none-any.whl.

File metadata

  • Download URL: creypy-3.1.0rc59-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for creypy-3.1.0rc59-py3-none-any.whl
Algorithm Hash digest
SHA256 a0970ac47e4ae08396dcfdc8745f8c1fbc2736bce0dbc06cff0327adec6528d2
MD5 c0a073ffe7889f7dff2df02a60f67406
BLAKE2b-256 a4dd6ac5fab70bfac51c46e81278e500c32280bad3294d9604f28ba02d2510f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for creypy-3.1.0rc59-py3-none-any.whl:

Publisher: ci.yml on creyD/creyPY

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page