query
Executes an SQL query and retrieves a Flow of ResultRows representing the returned data.
Return
A Flow of ResultRows with the data returned by the executed query.
Example usage:
val connection: Connection = // Obtain a connection from your R2DBC connection factory
val sql = "SELECT * FROM users WHERE age ?"
val age = 18
connection.query(sql) { bind(0, age) }
.collect { row ->
println("User: ${row["name"]}, Age: ${row["age"]}")
}
Content copied to clipboard
Parameters
sql
The SQL query string to be executed.
prepare
An optional lambda for preparing the statement, which allows you to configure the statement further before executing it (e.g., bind parameters). Defaults to an empty lambda.