Postgrex.prepare
You're seeing just the function
prepare
, go back to Postgrex module for more information.
Specs
prepare(conn(), iodata(), iodata(), [option()]) :: {:ok, Postgrex.Query.t()} | {:error, Exception.t()}
Prepares an (extended) query and returns the result as
{:ok, %Postgrex.Query{}}
or {:error, %Postgrex.Error{}}
if there was an
error. Parameters can be set in the query as $1
embedded in the query
string. To execute the query call execute/4
. To close the prepared query
call close/3
. See Postgrex.Query
for the query data.
This function may still raise an exception if there is an issue with types
(ArgumentError
), connection (DBConnection.ConnectionError
), ownership
(DBConnection.OwnershipError
) or other error (RuntimeError
).
Options
:queue
- Whether to wait for connection in a queue (default:true
);:timeout
- Prepare request timeout (default:15000
);:mode
- set to:savepoint
to use a savepoint to rollback to before the prepare on error, otherwise set to:transaction
(default::transaction
);
Examples
Postgrex.prepare(conn, "", "CREATE TABLE posts (id serial, title text)")