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

Uploaded Python 3

File details

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

File metadata

  • Download URL: eripotter_common-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 bccbac732474f36264b06ba2c23ad3dcafd113a4f193ab2e0187a68f5fd0ced9
MD5 8123c4dd2a9a54decb483bb8860d5132
BLAKE2b-256 108d69c70ce40f2111c3a91423971fba8666628d4d0792611f749cbf28de6c0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eripotter_common-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0854deb7f8b7edfb6b508e481b550ff474117839451c568cb02192f06df3c473
MD5 5c69538af182fff9039adb3f4daf24b2
BLAKE2b-256 256a78bf672ba6630bda480302876ad566eba275611db2b807d1ec12fe997de9

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