Skip to main content

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 3.11 or later

Installation

Basic installation:

pip install sqldb-logging

Installation with optional dependencies:

pip install sqldb-logging[databricks,mssql,mysql,postgresql]

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:

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

sqldb_logging-0.1.7.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqldb_logging-0.1.7-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file sqldb_logging-0.1.7.tar.gz.

File metadata

  • Download URL: sqldb_logging-0.1.7.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqldb_logging-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b73445e45325e3f4289996dc1c86a9d979d54d4f9895a920a7500509feb76641
MD5 04ca91de69b6ca46cc9e61549d16e848
BLAKE2b-256 59c10d54b08beccdb02fb4634954efbbb995d341edddb524b975bd303a492daa

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldb_logging-0.1.7.tar.gz:

Publisher: python-publish.yml on shurihar/sqldb-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqldb_logging-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: sqldb_logging-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqldb_logging-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 63cb8bfbce87ed9c0146744d96ad6706c39e69b51702307f2a2f58c261ea9f53
MD5 369af909710b87bacdc4241d585ea02a
BLAKE2b-256 9f3d15ce4e0ec772d4d353b0ee4638ea563e08644fb1533526fd705d1f43af50

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldb_logging-0.1.7-py3-none-any.whl:

Publisher: python-publish.yml on shurihar/sqldb-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page