5X Redshift Auth Manager
A simple Python library for managing AWS Redshift connections using environment variables. This library provides an easy way to authenticate and connect to AWS Redshift clusters with comprehensive error handling and connection management.
🚀 Features
- Streamlined AWS Redshift authentication with environment variables
- Automatic credential validation and connection testing
- Comprehensive error handling for production reliability
- Built-in connection testing utilities
- Context manager support for connection management
- Secure credential handling with environment variables
📦 Installation
pip install 5x-redshift-auth-manager
🔧 Configuration
Set the following environment variables:
export FIVEX_REDSHIFT_HOST="your-redshift-cluster.region.redshift.amazonaws.com"
export FIVEX_REDSHIFT_PORT="5439" # Optional, defaults to 5439
export FIVEX_REDSHIFT_DATABASE="your_database"
export FIVEX_REDSHIFT_USER="your_username"
export FIVEX_REDSHIFT_PASSWORD="your_password"
💻 Usage
Basic Usage
from redshift_auth import RedshiftConnectionManager
# Create connection manager
manager = RedshiftConnectionManager()
# Get connection
connection = manager.get_connection()
# Execute queries
with manager.get_cursor() as cursor:
cursor.execute("SELECT * FROM your_table LIMIT 10")
results = cursor.fetchall()
print(results)
# Close connection when done
manager.close_connection()
Using Context Manager
from redshift_auth import RedshiftConnectionManager
# Use context manager for automatic connection cleanup
with RedshiftConnectionManager() as manager:
connection = manager.get_connection()
with manager.get_cursor() as cursor:
cursor.execute("SELECT version()")
version = cursor.fetchone()
print(f"Redshift version: {version[0]}")
Error Handling
from redshift_auth import RedshiftConnectionManager
try:
manager = RedshiftConnectionManager()
connection = manager.get_connection()
print("Successfully connected to Redshift!")
except ValueError as e:
print(f"Configuration error: {e}")
except ConnectionError as e:
print(f"Connection error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
🔒 Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
FIVEX_REDSHIFT_HOST |
✅ | - | Redshift cluster endpoint |
FIVEX_REDSHIFT_PORT |
❌ | 5439 | Redshift port number |
FIVEX_REDSHIFT_DATABASE |
✅ | - | Database name |
FIVEX_REDSHIFT_USER |
✅ | - | Database username |
FIVEX_REDSHIFT_PASSWORD |
✅ | - | Database password |
🛠️ API Reference
RedshiftConnectionManager
Methods
__init__(): Initialize the connection managerget_connection(): Get or create a Redshift connectionget_cursor(): Get a database cursor for executing queriesclose_connection(): Close the connection__enter__()/__exit__(): Context manager support
Error Handling
The library provides specific error handling for:
- ValueError: Missing or invalid environment variables
- ConnectionError: Network connectivity issues
- psycopg2.OperationalError: Database connection issues
- psycopg2.DatabaseError: Database-specific errors
🔍 Requirements
- Python 3.8 or higher
- psycopg2-binary >= 2.9.0
📝 License
This project is licensed under the MIT License.
🤝 Support
- 🌐 Website: www.5x.co
- 📧 Email: support@5x.co
- 🐛 Issues: GitHub Issues
🚀 Developed by 5X | Powering Secure & Scalable Data Platforms
Metadata
Release files for 5x-redshift-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 | Provenance | Actions |
|---|---|---|---|---|
| 5x_redshift_auth_manager-0.1.0.tar.gz | 4.5 kB | Without provenance | Details for 5x_redshift_auth_manager-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 5x_redshift_auth_manager-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for 5x_redshift_auth_manager-0.1.0-py3-none-any.whl |
Total release size: 9.4 kB
Release files / 5x_redshift_auth_manager-0.1.0.tar.gz
| Download URL | 5x_redshift_auth_manager-0.1.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e03421b5f38790c571d75ce36e68cc7ac2b13321b19f2fad9d682918a7ba8609
|
|
BLAKE2b-256 checksum How to use checksums |
4df3804752449f43366cc3aa7a3880f1579e2fde73c95a3a5ec370199928dfe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Release files / 5x_redshift_auth_manager-0.1.0-py3-none-any.whl
| Download URL | 5x_redshift_auth_manager-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce2388f38f80f6aef5052110336e56fcfd0d9f5310b1c83a6489df3dd415b98a
|
|
BLAKE2b-256 checksum How to use checksums |
95580f91a21ebe6a1cf0d07503c37b893e7841d31876bdd35c6b3900b5786794
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.6
|
Security for 5x-redshift-auth-manager 0.1.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.