5x-postgresql-auth-manager
A Python package to manage PostgreSQL connections using environment variables.
Installation
pip install 5x-postgresql-auth-manager
Usage
This package simplifies connecting to PostgreSQL by reading connection details from environment variables. It provides a PostgreSQLConnectionManager class that handles connection establishment and management.
Environment Variables
Set the following environment variables with your PostgreSQL connection details:
FIVEX_POSTGRESQL_HOST: The hostname or IP address of your PostgreSQL server.FIVEX_POSTGRESQL_PORT: The port number of your PostgreSQL server (defaults to5432).FIVEX_POSTGRESQL_DATABASE: The name of the database to connect to.FIVEX_POSTGRESQL_USER: The username for connecting to the database.FIVEX_POSTGRESQL_PASSWORD: The password for the specified user.
Example
import os
from postgresql_auth.postgresql_auth import PostgreSQLConnectionManager
# Set environment variables (replace with your actual credentials)
os.environ['FIVEX_POSTGRESQL_HOST'] = 'localhost'
os.environ['FIVEX_POSTGRESQL_PORT'] = '5432'
os.environ['FIVEX_POSTGRESQL_DATABASE'] = 'mydatabase'
os.environ['FIVEX_POSTGRESQL_USER'] = 'myuser'
os.environ['FIVEX_POSTGRESQL_PASSWORD'] = 'mypassword'
try:
manager = PostgreSQLConnectionManager()
with manager.get_connection() as conn:
print("Successfully connected to PostgreSQL!")
with conn.cursor() as cursor:
cursor.execute("SELECT version();")
version = cursor.fetchone()
print(f"PostgreSQL Version: {version[0]}")
except ValueError as e:
print(f"Configuration Error: {e}")
except ConnectionError as e:
print(f"Connection Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Metadata
Release files for 5x-postgresql-auth-manager 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| 5x_postgresql_auth_manager-0.1.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 5x_postgresql_auth_manager-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / 5x_postgresql_auth_manager-0.1.0.tar.gz
| Download URL | 5x_postgresql_auth_manager-0.1.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f515f30a33a96cc9bdd86d5edfe3c085ba50cd02e0124b43911b5896c3b0d4d6
|
|
BLAKE2b-256 checksum How to use checksums |
2d0bcb83af76a12c5dab4c1c7129fff2361471d6365ab4c2aa823ef0531a53be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Release files / 5x_postgresql_auth_manager-0.1.0-py3-none-any.whl
| Download URL | 5x_postgresql_auth_manager-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3584ad839dda702e2a3604d0f22d2c2184150aeaf25383e4a71528e2fdadab75
|
|
BLAKE2b-256 checksum How to use checksums |
2f3ca78551065e94418330140fe459501971a0157fbdfdbeed146a44a9e5d5ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|