A batch operation wrapper for executing multiple parameter sets efficiently.
This class provides a type-safe way to execute batch operations with prepared statements. It uses type classes (BatchBinder and ParameterBinder) to automatically bind parameters of various types, making batch operations both safe and convenient.
Value parameters
preparedStatement
the prepared statement to use for batch operations
Adds multiple parameter sets to the batch for execution.
Adds multiple parameter sets to the batch for execution.
This method uses the BatchBinder type class to automatically bind parameters of the specified type. The type class provides compile-time safety for parameter binding.
Clears all parameter sets from the batch without executing them.
Clears all parameter sets from the batch without executing them.
This method removes all previously added parameter sets from the batch, allowing you to start over with new parameter sets.
Attributes
Returns
Right(this) on success, Left(DuckDBError) on failure
Since
0.1.0
Example
val result = for { batch <- Right(DuckDBBatch(stmt)) _ <-
batch.addBatch(("Alice", 25)) _ <- batch.clearBatch() // Remove Alice _
<- batch.addBatch(("Bob", 30)) // Add Bob instead result <-
batch.executeBatch() } yield result
val result = for { batch <- Right(DuckDBBatch(stmt)) _ <-
batch.addBatch(("Alice", 25), ("Bob", 30)) result <-
batch.executeBatch() } yield result
result match { case Right(batchResult) => println(s"Successful operations:
${batchResult.successCount}") println(s"Failed operations:
${batchResult.failureCount}") case Left(error) => println(s"Batch
execution failed: $error") }