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
-
Install the package:
pip install pgsql-connection-handler
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pgsql-connection-handler-1.0.0b0.tar.gz
.
File metadata
- Download URL: pgsql-connection-handler-1.0.0b0.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3829e2862436bd16a6896150d45ecb42a5dc44ae32ac41d5fd31bea9b290500d |
|
MD5 | b551f51f49acd0ced9be99c9b2403c9a |
|
BLAKE2b-256 | fd4ad785cf94c6751c3d269a7adc180e8947f427d5cd0385b083d3c450989a0f |
File details
Details for the file pgsql_connection_handler-1.0.0b0-py3-none-any.whl
.
File metadata
- Download URL: pgsql_connection_handler-1.0.0b0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2dd9d5fe220b5b27f996f5acf1272c0555a4cef4f81d478cc3292538da0c261 |
|
MD5 | f7b69f4727dd44cdded0d95892e6e5a7 |
|
BLAKE2b-256 | ce21ed0eda17dad050b372e090c27de368647b55abf6eb26f1c332ae45f9432d |