DBConnection.stream
You're seeing just the function
stream
, go back to DBConnection module for more information.
Specs
stream(t(), query(), params(), opts :: Keyword.t()) :: DBConnection.Stream.t()
Create a stream that will execute a prepared query and stream results using a cursor.
Options
:queue
- Whether to block waiting in an internal queue for the connection's state (boolean, default:true
). See "Queue config" instart_link/2
docs:timeout
- The maximum time that the caller is allowed to perform this operation (default:15_000
):deadline
- If set, overrides:timeout
option and specifies absolute monotonic time in milliseconds by which caller must perform operation. SeeSystem
module documentation for more information on monotonic time (default:nil
):log
- A function to log information about a call, either a 1-arity fun,{module, function, args}
withDBConnection.LogEntry.t/0
prepended toargs
ornil
. SeeDBConnection.LogEntry
(default:nil
)
The pool and connection module may support other options. All options
are passed to handle_declare/4
and handle_deallocate/4
.
Example
DBConnection.transaction(pool, fn conn ->
query = %Query{statement: "SELECT id FROM table"}
query = DBConnection.prepare!(conn, query)
try do
stream = DBConnection.stream(conn, query, [])
Enum.to_list(stream)
after
# Make sure query is closed!
DBConnection.close(conn, query)
end
end)