An extension to the Python logging library that allows logging to SQL databases using SQLAlchemy
Project description
sqldb-logging
An extension to the Python logging library that allows logging to SQL databases using SQLAlchemy
Requirements
- Python version 3.11 or later
Installation
Basic installation:
pip install sqldb-logging
Installation with optional dependencies:
pip install sqldb-logging[databricks]
Usage
import logging
from sqldb_logging.handlers import SQLHandler
handler = SQLHandler(
table='log_table',
drivername='postgresql+psycopg',
username='postgres',
password='postgres',
host='localhost',
port=5432,
database='postgres',
schema='public'
)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logger.addHandler(handler)
logger.info('Doing something')
Note: The database user must have CREATE TABLE permission to create a log table if it doesn't exist. If the log table already exists, its schema must reflect the structure of LogRecord
Supported databases
In theory, any database supported by SQLAlchemy should work. The following databases have been confirmed to work:
- MySQL
- PostgreSQL
- SQLite
- Databricks
- Microsoft SQL Server
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqldb_logging-0.1.4.tar.gz.
File metadata
- Download URL: sqldb_logging-0.1.4.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
132c81ed157f6e975cb3abb0f79cac5cf9dde5199f53e86d65a6dcc3e8e90f14
|
|
| MD5 |
84c33b9fedd44e8cafb4bee2d2ff8cfc
|
|
| BLAKE2b-256 |
409322200a0574c0f5444262608dbbca009dd944e1d7625550e92a37a0c177eb
|
Provenance
The following attestation bundles were made for sqldb_logging-0.1.4.tar.gz:
Publisher:
python-publish.yml on shurihar/sqldb-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqldb_logging-0.1.4.tar.gz -
Subject digest:
132c81ed157f6e975cb3abb0f79cac5cf9dde5199f53e86d65a6dcc3e8e90f14 - Sigstore transparency entry: 937694227
- Sigstore integration time:
-
Permalink:
shurihar/sqldb-logging@753dd0360bc76cae8173d897f30414332378b764 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/shurihar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@753dd0360bc76cae8173d897f30414332378b764 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sqldb_logging-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sqldb_logging-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89748633ce168b84fc7732e28ca4573bb635bb84997a1e86c5d57b1d27e6bd80
|
|
| MD5 |
9842049268094a11a025689f91e48c12
|
|
| BLAKE2b-256 |
7545ecbee40b68fe3e0d6a3134e535f4de4c51d61abcb7e6c16f64a8c21c8453
|
Provenance
The following attestation bundles were made for sqldb_logging-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on shurihar/sqldb-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqldb_logging-0.1.4-py3-none-any.whl -
Subject digest:
89748633ce168b84fc7732e28ca4573bb635bb84997a1e86c5d57b1d27e6bd80 - Sigstore transparency entry: 937694231
- Sigstore integration time:
-
Permalink:
shurihar/sqldb-logging@753dd0360bc76cae8173d897f30414332378b764 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/shurihar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@753dd0360bc76cae8173d897f30414332378b764 -
Trigger Event:
release
-
Statement type: