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.12.tar.gz
(10.5 kB
view details)
Built Distribution
File details
Details for the file fastapi_validation-1.1.12.tar.gz
.
File metadata
- Download URL: fastapi_validation-1.1.12.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e6546786df3c025911ec221c5e609319cdb1e956295f4233fa7cd6e07588787 |
|
MD5 | 8735d1c6fbc68f11ae3a6a76f4181042 |
|
BLAKE2b-256 | 2df25a117d2d52039a6dff55f72779e1860be3374a6c26710f25c8b76c5b6c0f |
File details
Details for the file fastapi_validation-1.1.12-py3-none-any.whl
.
File metadata
- Download URL: fastapi_validation-1.1.12-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcf5594e8af88b08c3ae1eaae0d76275faa2efee4bc52595dcdeefaf9f7283d3 |
|
MD5 | 16342ba29ca55b5222fba2112373ac41 |
|
BLAKE2b-256 | fc07774b635eba0093be48cf6ba1fb84a5d73fc86aa8eff9250eececb66075c4 |