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.2.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.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eripotter_common-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 645c630d078a7b57611ae5c9a4ebc2deeaf66ca1d937d909a62cc3050f16454a
MD5 e326e6370029e7c883f5ff7489037dd0
BLAKE2b-256 0961aa7df8aee1fd46e9d0e84dd8f6a854812face7cdb17dbeadaacd28241d15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eripotter_common-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 555c8c5de80e82e536aee0f2976af93c3cd3d0b92f1b9b303565f53830334461
MD5 f20f3307b45c7304d234066545c93970
BLAKE2b-256 cdacceb0d5b72c9645cdb56a4e4df7b8ad0e1923f3c778b63f587cd70e684cd5

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