-
Notifications
You must be signed in to change notification settings - Fork 0
Home
David H. edited this page Mar 31, 2025
·
2 revisions
Welcome to the LitePolis-database-example wiki!
This package provides database management for LitePolis applications using SQLModel.
- SQLModel Integration: Combines SQLAlchemy and Pydantic
- Manager Pattern: Clean separation of database operations
-
Unified Interface: Single
DatabaseActor
for all operations
classDiagram
class DatabaseActor {
+create_user()
+create_conversation()
+read_users()
+read_conversations()
}
DatabaseActor --|> UserManager
DatabaseActor --|> ConversationManager
DatabaseActor --|> CommentManager
- Import DatabaseActor:
from litepolis_database_example import DatabaseActor
- Use in Endpoints:
@router.post("/users/")
async def create_user(user_data: dict):
user = DatabaseActor.create_user(**user_data)
return user
-
id
: Primary key -
email
: Unique identifier -
password
: Hashed password -
privilege
: Access level
-
id
: Primary key -
title
: Conversation title -
description
: Detailed description -
creator_id
: Foreign key to User
Run tests with:
pytest tests/
Include in your router's setup.py
:
install_requires=['litepolis-database-example']