Metadata-Version: 2.1
Name: fastapi-healthcheck-sqlalchemy
Version: 0.1.0
Summary: A service to check the health of your applications SQLAlchemy connection.
Home-page: https://github.com/jtom38/fastapi_healthcheck_sqlalchemy
Author: James Tombleson
Author-email: luther38@gmail.com
Requires-Python: >=3.9,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: FastAPI-SQLAlchemy (>=0.2.1,<0.3.0)
Requires-Dist: fastapi-healthcheck (>=0.2.2,<0.3.0)
Project-URL: Repository, https://github.com/jtom38/fastapi_healthcheck_sqlalchemy
Description-Content-Type: text/markdown

# fastapi-healthcheck-sqlalchemy

A module built on top of fastapi_healthcheck to check the status of your SQLAlchemy connection.  This requires a Table given to the health check so it can run a count of rows against it.  As long as it returns a value, the connection is alive.

## Install

`pip install fastapi-healthcheck-sqlalchemy` or `poetry add fastapi-healthcheck-sqlalchemy`

## How to use

This module just exposes the service layer that will be used to parse your middleware connection to your database.  

```python
from fastapi import FastAPI
from fastapi_sqlalchemy import DBSessionMiddleware
from fastapi_healthcheck import HealthCheckFactory, healthCheckRoute
from fastapi_healthcheck_sqlalchemy import HealthCheckSQLAlchemy


app = FastAPI()

# Bring SQLAlchemy online first.
app.add_middleware(DBSessionMiddleware, db_url=cs.value)

_healthChecks = HealthCheckFactory()
_healthChecks.add(
    HealthCheckSQLAlchemy(
        # The name of the object for your reference
        alias='postgres db',  

        # The Table that we will run a count method against.
        table=SmtpContactsSqlModel, 

        tags=('postgres', 'db', 'sql01')
    )
)

app.add_api_route('/health', endpoint=healthCheckRoute(factory=_healthChecks))
```

