Batch Write
tools.batch_write(ToolBatchWriteParams**kwargs) -> ToolBatchWriteResponse
/api/v1/tools/batch-write
Write records to multiple tables in a single transaction.
Supports:
- Batch references: Use "_ref" to label records, "@refname" to reference them
- Natural keys: Use human-readable values for foreign keys (e.g., recipe name)
- Automatic FK ordering: Tables are inserted in dependency order
- Upsert mode: Update existing records based on match columns
- Dry run: Validate without committing changes
Parameters
tables: Dict[str, Iterable[Dict[str, object]]]
Map of table_name to list of records to insert.
Returns
Batch Write
from labric import Labric
client = Labric(
api_key="My API Key",
)
response = client.tools.batch_write(
tables={
"foo": [{
"foo": "bar"
}]
},
)
print(response.refs)
{
"refs": {
"foo": "string"
},
"summary": {
"foo": {
"created": 0,
"updated": 0
}
},
"plan": {
"insert_order": [
"string"
],
"operations": [
{
"foo": "bar"
}
]
},
"records": {
"foo": [
{
"foo": "bar"
}
]
},
"success": true
}
Returns Examples
{
"refs": {
"foo": "string"
},
"summary": {
"foo": {
"created": 0,
"updated": 0
}
},
"plan": {
"insert_order": [
"string"
],
"operations": [
{
"foo": "bar"
}
]
},
"records": {
"foo": [
{
"foo": "bar"
}
]
},
"success": true
}