Provides interface to incrementally build and execute SQL statements.
import java.sql.Connection
import scala.language.implicitConversions
import little.sql.{ *, given }
implicit val conn: Connection = ???
QueryBuilder("select * from users where group = ? and enabled = ?")
.params("staff", true) // Set input parameter values
.maxRows(10) // Limit result set to 10 rows
.foreach { rs => printf(s"uid=%d%n", rs.getInt("id")) } // Use implicit connection
// Same as above except use map of parameters
QueryBuilder("select * from users where group = ${group} and enabled = ${enabled}")
.params("group" -> "staff", "enabled" -> true)
.maxRows(10)
.foreach { rs => printf(s"uid=%d%n", rs.getInt("id")) }
- Companion:
- object
Value members
Abstract methods
Executes statement and passes result to supplied handler.
Executes statement and passes result to supplied handler.
- Value parameters:
- conn
connection to execute statement
- handler
execution handler
Executes query and passes result set to supplied function.
Executes query and passes result set to supplied function.
- Value parameters:
- conn
connection to execute query
- f
function
Concrete methods
Executes update and returns update count.
Executes update and returns update count.
- Value parameters:
- conn
connection to execute update
Executes query and maps first row of result set using supplied function.
Executes query and maps first row of result set using supplied function.
If the result set is not empty, and if the supplied function's return
value is not null, then Some
value is returned; otherwise, None
is
returned.
- Value parameters:
- conn
connection to execute query
- f
function
Executes query and builds collection using elements mapped from each row of result set.
Executes query and builds collection using elements mapped from each row of result set.
- Value parameters:
- conn
connection to execute query
- f
map function
Executes query and folds result set to single value using given initial value and binary operator.
Executes query and folds result set to single value using given initial value and binary operator.
- Value parameters:
- conn
connection to execute query
- init
initial value
- op
binary operator
Executes query and invokes supplied function for each row of result set.
Executes query and invokes supplied function for each row of result set.
- Value parameters:
- conn
connection to execute query
- f
function
Executes query and maps each row of result set using supplied function.
Executes query and maps each row of result set using supplied function.
- Value parameters:
- conn
connection to execute query
- f
map function