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.16.tar.gz
(11.4 kB
view details)
Built Distribution
File details
Details for the file fastapi_validation-1.1.16.tar.gz
.
File metadata
- Download URL: fastapi_validation-1.1.16.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b301be369d1b67387ca876b676a011fcc5172daa2fcdeca86fdb8967defe85f |
|
MD5 | 42daa90cb04cb7c0d087b443519560e8 |
|
BLAKE2b-256 | 5fc0609c5c0e4676cc63a78eb30ea1a579206c6bf1c3e8a6ead0fb7dfd0441fe |
File details
Details for the file fastapi_validation-1.1.16-py3-none-any.whl
.
File metadata
- Download URL: fastapi_validation-1.1.16-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24c9dbc40504873b17d0b70e721b07be01a9fb645695bdc84bb754f35ef58dfb |
|
MD5 | ab99692b7330b07b68d8aad8efc9905f |
|
BLAKE2b-256 | 4d91ad4868b08b750b1e1221db1ee6371ef1c6a63b93190afcc42a33260f4caa |