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.3.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

fastapi_validation-1.1.3-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_validation-1.1.3.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for fastapi_validation-1.1.3.tar.gz
Algorithm Hash digest
SHA256 70acf30ba72a1044ee449880f9b41a1a6367c500aed6946d57b5762b28cca2c4
MD5 4222a61657bebccd4e00e774788e8e38
BLAKE2b-256 bff22fe7052e05a467a6725b447959780e1db070645120eaae76400fc8d728c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_validation-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0995f32a7d1472167db5e9a30206901c5c9309a79e53197cff7883a00917edb5
MD5 2b7a6020cad54e5c633ce711304ec03d
BLAKE2b-256 163f7879c7b6bffe65725d476615b8098d7ed298b795bf961d482541b80a3402

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