Skip to main content

Common utilities for EriPotter microservices

Project description

EriPotter Common

Common utilities for EriPotter microservices.

Features

  • Database management with SQLAlchemy
    • Railway PostgreSQL support
    • Sync/Async database support
    • Session management
    • Connection pooling
  • Security utilities
    • Password hashing with bcrypt
    • JWT token management
  • Environment variables and API keys
    • Centralized configuration
    • API key management

Installation

pip install eripotter-common

Usage

Database

from eripotter_common.database import get_db_engine, get_session
from eripotter_common.www import DATABASE_URL

# Use default engine (configured in www.env)
with get_session() as session:
    result = session.query(YourModel).all()

# Or create custom engine
engine = get_db_engine("your-database-url")

# Async support
from eripotter_common.database import get_async_db_engine, get_async_session

async with get_async_session() as session:
    result = await session.query(YourModel).all()

Security

from eripotter_common.security import hash_password, verify_password

# Hash password
hashed = hash_password("mypassword")

# Verify password
is_valid = verify_password("mypassword", hashed)

# JWT tokens
from eripotter_common.security import create_access_token

token = create_access_token(
    data={"sub": "user@example.com"},
    secret_key="your-secret-key"
)

Environment Variables & API Keys

from eripotter_common.www import (
    OPENAI_API_KEY,
    DATABASE_URL,
    ASYNC_DATABASE_URL,
)

# Use API keys
openai.api_key = OPENAI_API_KEY

# Use database URLs
engine = get_db_engine(DATABASE_URL)

Development

  1. Clone the repository
  2. Install development dependencies:
    pip install -e ".[test]"
    
  3. Run tests:
    pytest
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

eripotter_common-0.1.3.tar.gz (5.6 MB view details)

Uploaded Source

Built Distribution

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

eripotter_common-0.1.3-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file eripotter_common-0.1.3.tar.gz.

File metadata

  • Download URL: eripotter_common-0.1.3.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for eripotter_common-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8bef502a3f8a8b1a5e69ec7718c99a56680b84c66e23dbf38c3d6638d308fa3b
MD5 6fe8bb1852858b4e9860ecde84e6a53a
BLAKE2b-256 0a59404425bec6fee45b5d6c004c98e791e394b206a0ad680f125c0e2cf0574e

See more details on using hashes here.

File details

Details for the file eripotter_common-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for eripotter_common-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d241465c9bd25123e2959b7d293fa85f2ac56c912aaeea38d2cbe0543bcf3156
MD5 d14781768c2ce118acebc08c2501f91d
BLAKE2b-256 cf22363f98d9e26ea787aff8014ce2a1d204d570e7c40a63ebe97c474ad123b7

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