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

Uploaded Python 3

File details

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

File metadata

  • Download URL: eripotter_common-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a03ed906b539c1c7e43a67c5455726e66e620f9fa22306eeea586c0c4b139843
MD5 76ea1756647415c25d759b762e42317f
BLAKE2b-256 8417e6ed94f4969189ff4427bd8222421d06dfea93ff78073c315843341f5a3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for eripotter_common-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4200d6fa4ed68d2a7832d3add83fd33f5c51414ff422b884cdbaf28fa8713f87
MD5 ff3021cb867a8fda72645cf636a5f235
BLAKE2b-256 52f5c2fad7895c262844f41dec62fe4ee7a679def9f7966d707c4e4f468a8913

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