Skip to main content

FastAPI Event

Project description

FastAPI Validation

FastAPI Validation support both SQLAlchemy for sql database and BeanieODM for nosql Database. To use the @Exists and @Unique decorator we need to set global-variable for the database_type Check the sample code below

For SQL Database using SQLAlchemy as ORM

from fastapi_validation import DatabaseTypeEnum

engine = create_engine(SQLALCHEMY_DATABASE_URL, echo=False, pool_size=50, max_overflow=100)
global_db_session: Session = sessionmaker(
    autoflush=False, autobegin=True, bind=engine, join_transaction_mode='rollback_only'
)()
def run_with_global_session(callback):
    try:
        return callback(global_db_session)
    except Exception as e:
        global_db_session.rollback()
        raise e

GlobalVariable.set('run_with_global_session', run_with_global_session)
GlobalVariable.set('database_type', DatabaseTypeEnum.SQL)

For Nosql Database using Beanie as ODM

GlobalVariable.set('database_type', DatabaseTypeEnum.NOSQL) # We can skip this line because the defautl database_type is SQL

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

fastapi_validation-1.1.13.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

fastapi_validation-1.1.13-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_validation-1.1.13.tar.gz.

File metadata

  • Download URL: fastapi_validation-1.1.13.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for fastapi_validation-1.1.13.tar.gz
Algorithm Hash digest
SHA256 3728a127d69330b5765eb7aee2414f43b37fda3cb94d6c07abbbea91a94b2bde
MD5 e54866bda14d950ec821893f29800485
BLAKE2b-256 c4fe2051aafffa8c7a6f77a72e1afd68ab8b1c346c6313e870590c696aa041c1

See more details on using hashes here.

File details

Details for the file fastapi_validation-1.1.13-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_validation-1.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 55cc8baf31bc13d5ae8ff4108b317d86051f0506c8076489f9955c73cb3ba7a0
MD5 64eb6c80b4e959b402239a1d7c5ea150
BLAKE2b-256 950ce78c8da4eb473740e77cb1047cb713181d8b8fae65fc6c5d0848effd8172

See more details on using hashes here.

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