Skip to content

bulk

Bulk operations for database controllers.

Classes:

Classes

BulkOperationsController

Python
BulkOperationsController(model: type[ModelT], db: DatabaseService)

Handles bulk create, update, and delete operations.

Initialize the bulk operations controller.

Parameters:

  • model (type[ModelT]) –

    The SQLModel to perform bulk operations on.

  • db (DatabaseService) –

    The database service instance.

Methods:

Functions

bulk_create async
Python
bulk_create(items: list[dict[str, Any]]) -> list[ModelT]

Create multiple records in bulk.

Returns:

  • list[ModelT]

    List of created records.

bulk_update async
Python
bulk_update(updates: list[tuple[Any, dict[str, Any]]]) -> int

Update multiple records in bulk.

Returns:

  • int

    Number of records updated.

bulk_delete async
Python
bulk_delete(record_ids: list[Any]) -> int

Delete multiple records in bulk.

Returns:

  • int

    Number of records deleted.

update_where async
Python
update_where(filters: Any, values: dict[str, Any]) -> int

Update records matching filters.

Returns:

  • int

    Number of records updated.

delete_where async
Python
delete_where(filters: Any) -> int

Delete records matching filters.

Returns:

  • int

    Number of records deleted.

bulk_upsert_with_conflict_resolution async
Python
bulk_upsert_with_conflict_resolution(
    items: list[dict[str, Any]],
    conflict_columns: list[str],
    update_columns: list[str] | None = None,
) -> list[ModelT]

Bulk upsert with conflict resolution.

Returns:

  • list[ModelT]

    List of upserted records.

Functions