DBConnection.prepare_execute

You're seeing just the function prepare_execute, go back to DBConnection module for more information.
Link to this function

prepare_execute(conn, query, params, opts \\ [])

View Source

Specs

prepare_execute(conn(), query(), params(), Keyword.t()) ::
  {:ok, query(), result()} | {:error, Exception.t()}

Prepare a query and execute it with a database connection and return both the prepared query and the result, {:ok, query, result} on success or {:error, exception} if there was an error.

The returned query can be passed to execute/4 and close/3.

Options

  • :queue - Whether to block waiting in an internal queue for the connection's state (boolean, default: true). See "Queue config" in start_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. See System 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} with DBConnection.LogEntry.t/0 prepended to args or nil. See DBConnection.LogEntry (default: nil)

Example

query                = %Query{statement: "SELECT id FROM table WHERE id=$1"}
{:ok, query, result} = DBConnection.prepare_execute(conn, query, [1])
{:ok, result2}       = DBConnection.execute(conn, query, [2])
:ok                  = DBConnection.close(conn, query)