8 Commits

Author SHA1 Message Date
Glauber Costa
e29fe1033d add a parameterized batch API to the embedded and serverless Python drivers
Add Connection.batch(statements, mode=None) to turso (bindings/python,
inherited by the sync driver's ConnectionSync and exposed on the aio
wrapper) and to turso_serverless, with the same signature and semantics
per the driver API parity requirement.

Statements are SQL strings or (sql, parameters) pairs and execute in
order, stopping at the first failure; the raised exception keeps its
DB-API class, prefixes the message with the zero-based statement index,
and carries batch_index and batch_results attributes — the latter with
one entry per statement, so callers can tell exactly which statements
took effect before the failure. A client-side value encoding failure is
reported the same way. With mode set (deferred, immediate, exclusive,
concurrent) the statements are wrapped in BEGIN/COMMIT with a ROLLBACK
on failure for all-or-nothing execution. batch() never opens a legacy
implicit transaction; statements join an already-open transaction, in
which case mode is ignored.

Each statement's BatchResult carries rows, description, rowcount, and
lastrowid, plus the server-side execution statistics rows_read,
rows_written, and query_duration_ms reported by the serverless protocol
(the embedded engine does not report them per statement). The
serverless driver sends the whole batch, including the transaction
wrapper, as a single pipeline request, so a multi-statement
parameterized batch is one HTTP round trip.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-28 10:40:26 -07:00
Nikita Sivukhin
28094f4b0b fix python bindings 2025-12-26 17:22:34 +04:00
Nikita Sivukhin
c1ca743503 adjust test 2025-12-09 15:42:29 +04:00
Nikita Sivukhin
731b9c1ec9 reformat and adjust test 2025-12-09 15:42:29 +04:00
Nikita Sivukhin
4c5dfbaefe format fixes 2025-12-09 15:42:29 +04:00
Nikita Sivukhin
4e910976d8 adjust tests 2025-12-09 15:42:29 +04:00
Nikita Sivukhin
9be21e259a wip 2025-12-09 15:42:29 +04:00
Nikita Sivukhin
a6454c8680 vibe coding aio python driver 2025-12-09 15:42:29 +04:00