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
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
fastapi_validation-1.1.5.tar.gz
(10.5 kB
view details)
Built Distribution
File details
Details for the file fastapi_validation-1.1.5.tar.gz
.
File metadata
- Download URL: fastapi_validation-1.1.5.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be35128c9d954c6692e81e96738baf75625f0650862a558205e59bd2835f0097 |
|
MD5 | 67e63baa8127e6e68d879fc806e4b485 |
|
BLAKE2b-256 | 1cd49ac688a0b8b80c7f62ad4da5f210442fd6dbfb55a65bba9bee4bdf36bc7a |
File details
Details for the file fastapi_validation-1.1.5-py3-none-any.whl
.
File metadata
- Download URL: fastapi_validation-1.1.5-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55010174c36dc46e4052b05bcb4bc54ca547fe09e265537dcf78bc40e72b4a77 |
|
MD5 | ade386f68e2821b53a71aae7b221547b |
|
BLAKE2b-256 | 19e5b2dab978e917619776c7fa6d820d5e3b9bc5a0e186b09a263d23f9618640 |