Skip to main content

A simple Python library for creating an AWS Athena client using access key, secret key and region.

Project description

5X AWS Athena Client Authentication Library

This Python library provides a simple way to create an AWS Athena client using AWS credentials. It handles authentication seamlessly, allowing developers to focus on querying Athena.

  • Authentication Method: AWS Credentials (Access Key and Secret Key)
  • Region Configuration: Configurable AWS Region

Installation

Install the package from PyPI using:

pip install 5x-aws-athena-auth-manager

Environment Variables

This library relies on environment variables for authentication.

Variable Description Example
FIVEX_ATHENA_AWS_ACCESS_KEY AWS Access Key ID AKIA1234567890EXAMPLE
FIVEX_ATHENA_AWS_SECRET_KEY AWS Secret Access Key wJalrXUtnFEMI/K7MDENG/123456
FIVEX_ATHENA_AWS_REGION AWS Region us-east-1

Example: Setting Environment Variables

export FIVEX_ATHENA_AWS_ACCESS_KEY="your-access-key"
export FIVEX_ATHENA_AWS_SECRET_KEY="your-secret-key"
export FIVEX_ATHENA_AWS_REGION="your-aws-region"

Usage

Import and Use in Python

from athena_auth import AthenaConnectionManager

try:
    manager = AthenaConnectionManager()
    client = manager.get_client()
    print("✅ Athena Client Created Successfully!")
except Exception as e:
    print(f"❌ Error: {e}")

Class Overview

AthenaConnectionManager

Creates and manages an AWS Athena client using environment variables.

How It Works

Validates AWS credentials from environment variables
Creates a boto3 Athena client with proper configuration
Tests the connection to ensure credentials are valid
Implements comprehensive error handling for debugging


Error Handling

The library provides detailed error handling with specific exceptions:

Exception Cause
ValueError Missing or invalid credentials
ClientError AWS API errors (invalid region, etc.)
ConnectionError Network or connectivity issues
Exception Unexpected errors during client creation

Example Error Handling

from athena_auth import AthenaConnectionManager
from botocore.exceptions import ClientError

try:
    manager = AthenaConnectionManager()
    client = manager.get_client()
except ValueError as e:
    print(f"❌ Configuration Error: {e}")
except ClientError as e:
    print(f"❌ AWS Client Error: {e}")
except ConnectionError as e:
    print(f"❌ Connection Error: {e}")
except Exception as e:
    print(f"❌ Unexpected Error: {e}")

Testing

The library includes comprehensive test utilities:

Simple Test

# simple_test.py
from athena_auth import AthenaConnectionManager

def test_athena_connection():
    manager = AthenaConnectionManager()
    client = manager.get_client()
    response = client.list_work_groups(MaxResults=1)
    print("✅ Connection successful!")

if __name__ == "__main__":
    test_athena_connection()

Full Test Suite

# Run the complete test suite
python test.py

Dependencies

Core dependencies required:

boto3>=1.26.0
botocore>=1.29.0

Why Use This Library?

Simplifies AWS Athena authentication – No need to manage credentials manually
Ensures proper credential validation – Validates credentials before use
Provides comprehensive error handling – Clear, actionable error messages
Includes testing utilities – Easy to verify your setup
Production-ready – Used by 5X platform services


Contributing

We welcome contributions! Please feel free to submit a Pull Request.


License

MIT License - feel free to use this library in your projects!

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

5x_aws_athena_auth_manager-0.1.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

5x_aws_athena_auth_manager-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file 5x_aws_athena_auth_manager-0.1.2.tar.gz.

File metadata

File hashes

Hashes for 5x_aws_athena_auth_manager-0.1.2.tar.gz
Algorithm Hash digest
SHA256 82f3245fca84648028606ba03305d8cd48fc13fa2ba7e2328eb66dd1a46c0c4f
MD5 13647cb360f64908cf1c1b1bb34d0d19
BLAKE2b-256 31c2bb229f8b9d6c46d0874cadd5500a01828bba5a28ff58b32c2c80e9e44397

See more details on using hashes here.

File details

Details for the file 5x_aws_athena_auth_manager-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for 5x_aws_athena_auth_manager-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b125b294bbdfcf7633ad263881b5746e448d6f2645f8ce8904e20ac0c30162a9
MD5 0ef95db35d79572bdd0a3affe8c129af
BLAKE2b-256 90fa1c1cd89465f18903f7a420486a84df1050d8a252a6ab54583424b52e3e83

See more details on using hashes here.

Supported by

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