Metadata-Version: 2.1
Name: fastapi_validation
Version: 1.1.0
Summary: FastAPI Event
Project-URL: Homepage, https://github.com/megatron-global/fastapi-validation
Project-URL: Bug Tracker, https://github.com/megatron-global/fastapi-validation/issues
Author-email: Dzung Nguyen <dung@megatron-solutions.com>, Harry Dang <harrydang.tech@gmail.com>
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: fastapi-exception~=1.3.0
Requires-Dist: fastapi-global-variable~=0.0.4
Requires-Dist: pydantic~=2.4.2
Requires-Dist: python-keycloak~=2.14.0
Requires-Dist: sqlalchemy~=2.0.4
Description-Content-Type: text/markdown

# FastAPI Validation

FastAPI Validation currently work with SQLAlchemy based behind, so we need to set it global when initialize

```python
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)
```
