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
- Clone the repository
- Install development dependencies:
pip install -e ".[test]"
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bccbac732474f36264b06ba2c23ad3dcafd113a4f193ab2e0187a68f5fd0ced9
|
|
| MD5 |
8123c4dd2a9a54decb483bb8860d5132
|
|
| BLAKE2b-256 |
108d69c70ce40f2111c3a91423971fba8666628d4d0792611f749cbf28de6c0c
|
File details
Details for the file eripotter_common-0.1.4-py3-none-any.whl.
File metadata
- Download URL: eripotter_common-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0854deb7f8b7edfb6b508e481b550ff474117839451c568cb02192f06df3c473
|
|
| MD5 |
5c69538af182fff9039adb3f4daf24b2
|
|
| BLAKE2b-256 |
256a78bf672ba6630bda480302876ad566eba275611db2b807d1ec12fe997de9
|