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

  • 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.6.tar.gz (6.5 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.6-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqldb_logging-0.1.6.tar.gz
  • Upload date:
  • Size: 6.5 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.6.tar.gz
Algorithm Hash digest
SHA256 60622788d54588a891465366399d709a99be0b1945b1beeceab3e829a395b49c
MD5 3aebd0a10d26ba0b84ebc6e1ecdde5ec
BLAKE2b-256 52500682ba6b908f95e402c9ce617570367c74b79ca4610ac050f1d4e47d8014

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqldb_logging-0.1.6.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.6-py3-none-any.whl.

File metadata

  • Download URL: sqldb_logging-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.9 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 920d4717831779e2e53d36dfa0c9d57f09d1c515694d509692de9770e3eef5f6
MD5 1f6a77fead85b93fa14841cf12e0a23d
BLAKE2b-256 d54b793cea62d59d1a5da24ce3c4836a8eb947835574b6087460a5489861aa65

See more details on using hashes here.

Provenance

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