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


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.0.0rc12.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

creyPY-3.0.0rc12-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file creypy-3.0.0rc12.tar.gz.

File metadata

  • Download URL: creypy-3.0.0rc12.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for creypy-3.0.0rc12.tar.gz
Algorithm Hash digest
SHA256 a8e658da210fbb6b2b11e623df21214cad05a12660887db7c688cf2329f19e25
MD5 b37ff6247857430aea802c1ba55fa0d6
BLAKE2b-256 4394edf32f803e4a03ebd9060c5cf071cc98e039a910d9dc35ce185eac95b312

See more details on using hashes here.

Provenance

The following attestation bundles were made for creypy-3.0.0rc12.tar.gz:

Publisher: ci.yml on creyD/creyPY

Attestations:

File details

Details for the file creyPY-3.0.0rc12-py3-none-any.whl.

File metadata

  • Download URL: creyPY-3.0.0rc12-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for creyPY-3.0.0rc12-py3-none-any.whl
Algorithm Hash digest
SHA256 0e8613628c0a74d2ec1d56bc429c9513130af221936e6e26bc3afcb5e616e032
MD5 9c39c367cfc4320f9af22eefa1f92a5f
BLAKE2b-256 1f1009fbf487c109658df1c8f403d46284ba7828dc5650b34d87328ac1012dd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for creyPY-3.0.0rc12-py3-none-any.whl:

Publisher: ci.yml on creyD/creyPY

Attestations:

Supported by

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