tisserande.db_oper.function_types

Attributes

python_function

member_function

shell_function

Classes

PythonFunctionOperations

Base class for Table operations with full type safety.

MemberFunctionOperations

Base class for Table operations with full type safety.

ShellFunctionOperations

Base class for Table operations with full type safety.

Module Contents

class tisserande.db_oper.function_types.PythonFunctionOperations(context: TableContext[T, ResponseT, CreateT])[source]

Bases: macon.db_oper.base.TableOperations[tisserande.db.function_types.PythonFunctionTable, tisserande.models.PythonFunction, tisserande.models.PythonFunctionCreate]

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)
class tisserande.db_oper.function_types.MemberFunctionOperations(context: TableContext[T, ResponseT, CreateT])[source]

Bases: macon.db_oper.base.TableOperations[tisserande.db.function_types.MemberFunctionTable, tisserande.models.MemberFunction, tisserande.models.MemberFunctionCreate]

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)
async get_create_kwargs(session: sqlalchemy.ext.asyncio.AsyncSession, class_id: macon.common.RowId | None = None, class_name: str | None = None, **kwargs: Any) dict[str, Any][source]

Prepare kwargs for creating an instance.

class tisserande.db_oper.function_types.ShellFunctionOperations(context: TableContext[T, ResponseT, CreateT])[source]

Bases: macon.db_oper.base.TableOperations[tisserande.db.function_types.ShellFunctionTable, tisserande.models.ShellFunction, tisserande.models.ShellFunctionCreate]

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)
tisserande.db_oper.function_types.python_function[source]
tisserande.db_oper.function_types.member_function[source]
tisserande.db_oper.function_types.shell_function[source]