tisserande.db_oper.edges
Attributes
Classes
Base class for Table operations with full type safety. |
Module Contents
- class tisserande.db_oper.edges.EdgeOperations(context: TableContext[T, ResponseT, CreateT])[source]
Bases:
macon.db_oper.base.TableOperations[tisserande.db.edges.EdgeTable,tisserande.models.Edge,tisserande.models.EdgeCreate]Base class for Table operations with full type safety.
Provides common CRUD operations for database tables with validation, lifecycle hooks, and complete type safety across database models and their Pydantic representations.
Type Parameters
- TTypeVar, bound=Base
Database model class (SQLAlchemy)
- ResponseTTypeVar, bound=BaseModel
Pydantic model class for responses
- CreateTTypeVar, bound=BaseModel
Pydantic model class for creation
Important
All methods that modify the database (create_row, create_rows, etc.) DO NOT commit transactions. The caller MUST manage transactions using async with session.begin() or explicit commit/rollback.
All create methods DO add objects to the session and flush them to get database-generated values (like auto-increment IDs), but the transaction must still be committed by the caller.
- param context:
Shared configuration for this operation
Examples
>>> from myapp.models import User, UserResponse, UserCreate >>> context = TableContext( ... db_class=User, ... response_class=UserResponse, ... create_class=UserCreate, ... class_string="user" ... ) >>> ops = TableOperations(context) >>> >>> async with get_session() as session: ... async with session.begin(): ... user = await ops.create_row( ... session, ... username="alice", ... email="alice@example.com" ... ) ... # user is type User (T) ... pydantic_user = ops.to_pydantic(user) ... # pydantic_user is type UserResponse (ResponseT)