[−][src]Struct sqlx::query::Query
Raw SQL query with bind parameters. Returned by [query
][crate::query::query].
Implementations
impl<'q, DB> Query<'q, DB, <DB as HasArguments<'q>>::Arguments> where
DB: Database,
[src]
DB: Database,
pub fn bind<T>(
self,
value: T
) -> Query<'q, DB, <DB as HasArguments<'q>>::Arguments> where
T: 'q + Encode<'q, DB> + Type<DB> + Send,
[src]
self,
value: T
) -> Query<'q, DB, <DB as HasArguments<'q>>::Arguments> where
T: 'q + Encode<'q, DB> + Type<DB> + Send,
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).
impl<'q, DB, A> Query<'q, DB, A> where
DB: Database + HasStatementCache,
[src]
DB: Database + HasStatementCache,
pub fn persistent(self, value: bool) -> Query<'q, DB, A>
[src]
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
.
impl<'q, DB, A> Query<'q, DB, A> where
A: Send + 'q + IntoArguments<'q, DB>,
DB: Database,
[src]
A: Send + 'q + IntoArguments<'q, DB>,
DB: Database,
pub fn map<F, O>(self, f: F) -> Map<'q, DB, impl TryMapRow<DB, Output = O>, A> where
F: MapRow<DB, Output = O>,
O: Unpin,
[src]
F: MapRow<DB, Output = O>,
O: Unpin,
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.
pub fn try_map<F>(self, f: F) -> Map<'q, DB, F, A> where
F: TryMapRow<DB>,
[src]
F: TryMapRow<DB>,
Map each row in the result to another type.
The query_as
method will construct a mapped query using
a FromRow
implementation.
pub async fn execute<'e, 'c, E>(
self,
executor: E
) -> Result<<DB as Database>::Done, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Result<<DB as Database>::Done, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute the query and return the total number of rows affected.
pub async fn execute_many<'e, 'c, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Done, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Done, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute multiple queries and return the rows affected from each query, in a stream.
pub fn fetch<'e, 'c, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute the query and return the generated results as a stream.
pub fn fetch_many<'e, 'c, E>(
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::Done, <DB as Database>::Row>, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Pin<Box<dyn Stream<Item = Result<Either<<DB as Database>::Done, <DB as Database>::Row>, Error>> + 'e + Send>> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute multiple queries and return the generated results as a stream from each query, in a stream.
pub async fn fetch_all<'e, 'c, E>(
self,
executor: E
) -> Result<Vec<<DB as Database>::Row>, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Result<Vec<<DB as Database>::Row>, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute the query and return all the generated results, collected into a Vec
.
pub async fn fetch_one<'e, 'c, E>(
self,
executor: E
) -> Result<<DB as Database>::Row, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Result<<DB as Database>::Row, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute the query and returns exactly one row.
pub async fn fetch_optional<'e, 'c, E>(
self,
executor: E
) -> Result<Option<<DB as Database>::Row>, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
[src]
self,
executor: E
) -> Result<Option<<DB as Database>::Row>, Error> where
'c: 'e,
'q: 'e,
A: 'e,
E: Executor<'c, Database = DB>,
Execute the query and returns at most one row.
Trait Implementations
impl<'q, DB, A> Execute<'q, DB> for Query<'q, DB, A> where
A: Send + IntoArguments<'q, DB>,
DB: Database,
[src]
A: Send + IntoArguments<'q, DB>,
DB: Database,
fn sql(&self) -> &'q str
[src]
fn statement(&self) -> Option<&<DB as HasStatement<'q>>::Statement>
[src]
fn take_arguments(&mut self) -> Option<<DB as HasArguments<'q>>::Arguments>
[src]
fn persistent(&self) -> bool
[src]
Auto Trait Implementations
impl<'q, DB, A> RefUnwindSafe for Query<'q, DB, A> where
A: RefUnwindSafe,
DB: RefUnwindSafe,
<DB as HasStatement<'q>>::Statement: RefUnwindSafe,
A: RefUnwindSafe,
DB: RefUnwindSafe,
<DB as HasStatement<'q>>::Statement: RefUnwindSafe,
impl<'q, DB, A> Send for Query<'q, DB, A> where
A: Send,
<DB as HasStatement<'q>>::Statement: Sync,
A: Send,
<DB as HasStatement<'q>>::Statement: Sync,
impl<'q, DB, A> Sync for Query<'q, DB, A> where
A: Sync,
DB: Sync,
<DB as HasStatement<'q>>::Statement: Sync,
A: Sync,
DB: Sync,
<DB as HasStatement<'q>>::Statement: Sync,
impl<'q, DB, A> Unpin for Query<'q, DB, A> where
A: Unpin,
DB: Unpin,
A: Unpin,
DB: Unpin,
impl<'q, DB, A> UnwindSafe for Query<'q, DB, A> where
A: UnwindSafe,
DB: UnwindSafe,
<DB as HasStatement<'q>>::Statement: RefUnwindSafe,
A: UnwindSafe,
DB: UnwindSafe,
<DB as HasStatement<'q>>::Statement: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,