Skip to main content

A package that connects to one or more PostgreSQL databases and allows you to retrieve a database connection when required. Depends on psycopg2-binary.

Project description

pgsql-connection-handler

A package that connects to one or more PostgreSQL databases and allows you to retrieve a database connection when required. Depends on psycopg2-binary.

Quickstart

  1. Install the package:

    pip install pgsql-connection-handler
    
  2. Use the package:

    from pg_connection_handler import databases, connect_databases
    
    DATABASES = {
        'default': {
            'dbname': 'mydatabase',
            'user': 'guido',
            'password': 'SuperS3cr!t',
            'host': 'localhost',
            'port': '5432',
            'sslmode': 'disable',
            'application_name': 'myapp',
        },
        'another_db': {
            'dbname': 'mydatabase',
            'user': 'guido',
            'password': 'SuperS3cr!t',
            'host': 'localhost',
            'port': '5432',
            'sslmode': 'disable',
            'application_name': 'myapp',
        },
    }
    connect_databases(DATABASES)
    
    db_connection = databases.get_connection()
    
    # Or get the connection based on the alias used in DATABASES
    db_connection = databases.get_connection('db_alias')
    
    # Or get the database object
    db = databases.get()
    db_connection = db.conn
    

Compatiblity

  • Compatible with Python 3.8 and above.

Versioning

This project follows semantic versioning (SemVer).

License, code of conduct and requirements

Check the root of the repo for these files.

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

pgsql-connection-handler-1.0.0b0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

pgsql_connection_handler-1.0.0b0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file pgsql-connection-handler-1.0.0b0.tar.gz.

File metadata

File hashes

Hashes for pgsql-connection-handler-1.0.0b0.tar.gz
Algorithm Hash digest
SHA256 3829e2862436bd16a6896150d45ecb42a5dc44ae32ac41d5fd31bea9b290500d
MD5 b551f51f49acd0ced9be99c9b2403c9a
BLAKE2b-256 fd4ad785cf94c6751c3d269a7adc180e8947f427d5cd0385b083d3c450989a0f

See more details on using hashes here.

File details

Details for the file pgsql_connection_handler-1.0.0b0-py3-none-any.whl.

File metadata

File hashes

Hashes for pgsql_connection_handler-1.0.0b0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2dd9d5fe220b5b27f996f5acf1272c0555a4cef4f81d478cc3292538da0c261
MD5 f7b69f4727dd44cdded0d95892e6e5a7
BLAKE2b-256 ce21ed0eda17dad050b372e090c27de368647b55abf6eb26f1c332ae45f9432d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page