Skip to main content

django-pgconnection provides primitives for overriding Postgres connection and cursor objects, making it possible to do the following:

  1. Hook into SQL generation. For example, it is not possible to log every time a SQL statement is executed in Django or annotate SQL with comments so that additional metadata is logged when executing queries. The pgconnection.pre_execute_hook context manager allows one to hook into SQL before it is executed.

  2. Route database traffic to a different database. Although Django provides the ability to construct custom database routers, routing to a different database has to be instrumented throughout code and can be tedious and error prone. The pgconnection.route context manager can route any database operations to a different database, even if it’s an external management command that has not been instrumented to use a different database.

The documentation has examples of how to use django-pgconnection.

Documentation

View the django-pgconnection docs here.

Installation

Install django-pgconnection with:

pip3 install django-pgconnection

After this, add pgconnection to the INSTALLED_APPS setting of your Django project.

In order to use connection routing and hooks, one must configure the DATABASES setting in settings.py like so:

DATABASES = pgconnection.configure({
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase',
    }
})

Contributing Guide

For information on setting up django-pgconnection for development and contributing changes, view CONTRIBUTING.rst.

Primary Authors

  • @wesleykendall (Wes Kendall)

Metadata

Release files for django-pgconnection 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-pgconnection 1.0.3
File Size Uploaded Provenance
django-pgconnection-1.0.3.tar.gz 8.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-pgconnection 1.0.3
File Interpreter ABI Platform
django_pgconnection-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / django-pgconnection-1.0.3.tar.gz

Download URL django-pgconnection-1.0.3.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
395d82fc6ca612b8575373c317d6f1a47974dadda965e043d2704609ded12c0a
BLAKE2b-256 checksum
How to use checksums
4ffa507cc09eedca06e0e37dc27f77be1e19ddc2f087d3c05b0b8ded8cebc62f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.13.0-1023-aws

Release files / django_pgconnection-1.0.3-py3-none-any.whl

Download URL django_pgconnection-1.0.3-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d2dadeb8b7bdf8ac94f2a5c553f6d96c446331c1f3e930dd6fc4f194bbec90a
BLAKE2b-256 checksum
How to use checksums
c779a767714bd196d48227480f2e5180dfdf57d99a36032fec5fc97a285cee09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.13.0-1023-aws

Security for django-pgconnection 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page