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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_validation-1.1.14.tar.gz
  • Upload date:
  • Size: 11.2 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.14.tar.gz
Algorithm Hash digest
SHA256 fd6ece9df5b4181cf8e4e71520576a2936b39f1209e5db413f3f67ef56ae00a9
MD5 bd9cd8111d6c5dd75aaedc871618f0c4
BLAKE2b-256 5852abfc44a7554a6c47c1e504ca1c99c87453dd92c8ea419b09a02c4e7a9b7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_validation-1.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 80f282f735dcce2a88d66f6365677f62cf66c5639c8bb35a0991e2ddb5a0e878
MD5 a2c9e4f0cb8240fda8db02adde25e290
BLAKE2b-256 f698b86869978c3a7b160fa21c5e4ca202d56cba949cc1f483ff5730f6758beb

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