Skip to main content

Psycopg2 logging / profiling tool

Project description

Psycopg2Logger

Psycopg2Logger is made to work with https://github.com/larswise/pgquerymon and is a logging library that captures PostgreSQL database queries from psycopg2 and transmits them via TCP to the monitoring application in real-time. It provides detailed SQL query logging with parameter interpolation, execution duration tracking. The logger is optimized for development use with connection pooling, reflection caching, compiled regex patterns, and async logging to minimize performance impact on your application. Do not run this in production; this is intended for development only.

Installation

Install the package via pip:

pip install psycopg2logger

Usage

For FastAPI Applications

from fastapi import FastAPI
from fastapisupport.middleware import Psycopg2InterceptorMiddleware

app = FastAPI()

# Add the middleware to your FastAPI application
app.add_middleware(Psycopg2InterceptorMiddleware)

@app.get("/example")
async def example_endpoint():
    # Your database logic here
    return {"message": "Example endpoint"}

# Run your FastAPI application
# uvicorn main:app --reload

Monitoring Application

To view the captured SQL queries, you'll need the companion monitoring application pgquerymon which provides a real-time dashboard for analyzing your database interactions.

Features

  • Real-time SQL logging with parameter interpolation
  • Execution duration tracking for performance analysis
  • Intelligent caller detection to identify source business logic
  • High-performance design with connection pooling and caching
  • Async logging to prevent blocking your application
  • Support for FastAPI applications
  • Configurable performance settings for different use cases

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

psycopg2logger-0.4.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

psycopg2logger-0.4.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file psycopg2logger-0.4.0.tar.gz.

File metadata

  • Download URL: psycopg2logger-0.4.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for psycopg2logger-0.4.0.tar.gz
Algorithm Hash digest
SHA256 66ebad89b545465d1b545dff330713da6ba590a8ea703b8c7522466aa85a09a5
MD5 bfef508705108009a9d8cfba083dc8d1
BLAKE2b-256 7520b79ab6b808492955bebbb31af3a124a226324cc0ef23c07bc12bbccb28bf

See more details on using hashes here.

File details

Details for the file psycopg2logger-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: psycopg2logger-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for psycopg2logger-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21f08fc8b631181e1e09898b6573cb5b50dc39894b9bfe6b573ec52fa375b755
MD5 5348023ee9f7917ddc42512e14cb7c28
BLAKE2b-256 7f2a38f86fc9dcbea7cf5b4fc04fd4a90bc436bec170f0b1c42273c004c6aaca

See more details on using hashes here.

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