Postgrex.prepare_execute

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

prepare_execute(conn, name, statement, params, opts \\ [])

View Source

Specs

prepare_execute(conn(), iodata(), iodata(), list(), [execute_option()]) ::
  {:ok, Postgrex.Query.t(), Postgrex.Result.t()} | {:error, Postgrex.Error.t()}

Prepares and executes a query in a single step.

It returns the result as {:ok, %Postgrex.Query{}, %Postgrex.Result{}} or {:error, %Postgrex.Error{}} if there was an error. Parameters are given as part of the prepared query, %Postgrex.Query{}.

See the README for information on how Postgrex encodes and decodes Elixir values by default. See Postgrex.Query for the query data and Postgrex.Result for the result data.

Options

  • :queue - Whether to wait for connection in a queue (default: true);
  • :timeout - Execute request timeout (default: 15000);
  • :decode_mapper - Fun to map each row in the result to a term after decoding, (default: fn x -> x end);
  • :mode - set to :savepoint to use a savepoint to rollback to before the execute on error, otherwise set to :transaction (default: :transaction);

Examples

Postgrex.prepare_execute(conn, "", "SELECT id FROM posts WHERE title like $1", ["%my%"])