Struct sqlx::query::Query

source · []
pub struct Query<'q, DB, A> where
    DB: Database
{ /* private fields */ }
Expand description

Raw SQL query with bind parameters. Returned by query.

Implementations

Bind a value for use with this SQL query.

If the number of times this is called does not match the number of bind parameters that appear in the query (? for most SQL flavors, $1 .. $N for Postgres) then an error will be returned when this query is executed.

There is no validation that the value is of the type expected by the query. Most SQL flavors will perform type coercion (Postgres will return a database error).

If true, the statement will get prepared once and cached to the connection’s statement cache.

If queried once with the flag set to true, all subsequent queries matching the one with the flag will use the cached statement until the cache is cleared.

Default: true.

Map each row in the result to another type.

See try_map for a fallible version of this method.

The query_as method will construct a mapped query using a FromRow implementation.

Map each row in the result to another type.

The query_as method will construct a mapped query using a FromRow implementation.

Execute the query and return the total number of rows affected.

Execute multiple queries and return the rows affected from each query, in a stream.

Execute the query and return the generated results as a stream.

Execute multiple queries and return the generated results as a stream from each query, in a stream.

Execute the query and return all the generated results, collected into a Vec.

Execute the query and returns exactly one row.

Execute the query and returns at most one row.

Trait Implementations

Gets the SQL that will be executed.

Gets the previously cached statement, if available.

Returns the arguments to be bound against the query string. Read more

Returns true if the statement should be cached.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.