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.5.tar.gz (6.1 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.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqldb_logging-0.1.5.tar.gz
  • Upload date:
  • Size: 6.1 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.5.tar.gz
Algorithm Hash digest
SHA256 68e1bbaa19ebb0df1a2e8668a94b814505d7b8d7dc11c55e13bfb116311f301a
MD5 e31638266078b58d55f54fd041e68f8b
BLAKE2b-256 db71745dfb8c70c339ff821c52fe18fe6364f47e36b3c28858bdf2d8529e29a1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sqldb_logging-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 67595c0d854f12ba76383a448be026f6f6a5813983b48b36f43c67a6d757fc6c
MD5 5152a870862b95877c9e75adb662b344
BLAKE2b-256 beca787b543815d1a9586a4c47477fc2b800be8ce0804f1022be983ed71db76b

See more details on using hashes here.

Provenance

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