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 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

sqldb_logging-0.1.4.tar.gz (6.0 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.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for sqldb_logging-0.1.4.tar.gz
Algorithm Hash digest
SHA256 132c81ed157f6e975cb3abb0f79cac5cf9dde5199f53e86d65a6dcc3e8e90f14
MD5 84c33b9fedd44e8cafb4bee2d2ff8cfc
BLAKE2b-256 409322200a0574c0f5444262608dbbca009dd944e1d7625550e92a37a0c177eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldb_logging-0.1.4.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.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

Hashes for sqldb_logging-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 89748633ce168b84fc7732e28ca4573bb635bb84997a1e86c5d57b1d27e6bd80
MD5 9842049268094a11a025689f91e48c12
BLAKE2b-256 7545ecbee40b68fe3e0d6a3134e535f4de4c51d61abcb7e6c16f64a8c21c8453

See more details on using hashes here.

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

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