Instance Method
execute(sql:_:)
Requests that the given generic SQL query be serialized and executed on the database, and that the
onRow closure be invoked once for each result row the query returns (if any).func execute(sql query: any SQLExpression, _ onRow: @escaping @Sendable (any SQLRow) -> ()) async throws
Parameters
queryAn
SQLExpressionrepresenting a complete query to execute.onRowA closure which is invoked once for each result row returned by the query (if any).
Discussion
If a concrete type conforming to SQLDatabase can provide a more efficient Concurrency-based implementation than forwarding the invocation through the legacy EventLoopFuture-based API, it should override this method in order to do so.
Default Implementations
SQLDatabase Implementations
execute(sql:_:)The default implementation forexecute(sql:_:).
See Also
Query interface
withSession(_:)Requests the provided closure be called with a database which is guaranteed to represent a single “session”, suitable for e.g. executing a series of queries representing a transaction.