A service to check the health of your applications SQLAlchemy connection.
Project description
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.
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))
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
Built Distribution
File details
Details for the file fastapi-healthcheck-sqlalchemy-0.1.0.tar.gz
.
File metadata
- Download URL: fastapi-healthcheck-sqlalchemy-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab0e47955fb37f5204aa642d4e5a884f1b58111f63c89f5936662091e910da7c |
|
MD5 | 9d6ceb8bdfa1242b0d4cbcd4d20f3aa3 |
|
BLAKE2b-256 | 714be6537559f9def1dfe3b9c27622f1fbec4c112cbb40850e48542cd6b76a26 |
File details
Details for the file fastapi_healthcheck_sqlalchemy-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: fastapi_healthcheck_sqlalchemy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.9 Darwin/20.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1edff5e07f8a6e0c23975fce23d3e995ba30b4fa52c643b94bd1831992c5ddd7 |
|
MD5 | 6512ba7f99d7f0d05b99aa3bd12d53b2 |
|
BLAKE2b-256 | 2e252d8f60bb10c12d236d914e28d9a3543d5a0ee55c65193aab8b6a16277272 |