[−][src]Struct sqlx_core::QueryAs
SQL query with bind parameters, which maps rows to an explicit output type.
Returned by query_as and [query!] et al.
The methods on this struct should be passed a reference to crate::Pool or one of the connection types.
Methods
impl<'_, DB, P> QueryAs<'_, DB, (), P> where
DB: Database,
P: IntoArguments<DB> + Send,
[src]
DB: Database,
P: IntoArguments<DB> + Send,
The result of [query!] for SQL queries that does not return output.
pub async fn execute<'_, E>(self, executor: &'_ mut E) -> Result<u64> where
E: Executor<Database = DB>,
[src]
E: Executor<Database = DB>,
Execute the query for its side-effects.
Returns the number of rows affected, or 0 if not applicable.
impl<'q, DB, R, P> QueryAs<'q, DB, R, P> where
DB: Database,
P: IntoArguments<DB> + Send,
R: Send + 'q,
[src]
DB: Database,
P: IntoArguments<DB> + Send,
R: Send + 'q,
pub fn fetch<'e, E>(
self,
executor: &'e mut E
) -> impl Stream<Item = Result<R>> + 'e where
E: Executor<Database = DB>,
'q: 'e,
[src]
self,
executor: &'e mut E
) -> impl Stream<Item = Result<R>> + 'e where
E: Executor<Database = DB>,
'q: 'e,
Execute the query, returning the rows as a futures Stream
.
Use [fetch_all] if you want a Vec
instead.
pub async fn fetch_all<'_, E>(self, executor: &'_ mut E) -> Result<Vec<R>> where
E: Executor<Database = DB>,
[src]
E: Executor<Database = DB>,
Execute the query and get all rows from the result as a Vec
.
pub async fn fetch_optional<'_, E>(
self,
executor: &'_ mut E
) -> Result<Option<R>> where
E: Executor<Database = DB>,
[src]
self,
executor: &'_ mut E
) -> Result<Option<R>> where
E: Executor<Database = DB>,
Execute a query which should return either 0 or 1 rows.
Returns crate::Error::FoundMoreThanOne if more than 1 row is returned.
Use .fetch().try_next()
if you just want one row.
pub async fn fetch_one<'_, E>(self, executor: &'_ mut E) -> Result<R> where
E: Executor<Database = DB>,
[src]
E: Executor<Database = DB>,
Execute a query which should return exactly 1 row.
- Returns crate::Error::NotFound if 0 rows are returned.
- Returns crate::Error::FoundMoreThanOne if more than one row is returned.
impl<'q, DB, R> QueryAs<'q, DB, R> where
DB: Database,
DB::Arguments: Arguments<Database = DB>,
[src]
DB: Database,
DB::Arguments: Arguments<Database = DB>,
pub fn bind<T>(self, value: T) -> Self where
DB: HasSqlType<T>,
T: Encode<DB>,
[src]
DB: HasSqlType<T>,
T: Encode<DB>,
Bind a value for use with this SQL query.
Logic Safety
This function should be used with care, as SQLx cannot validate that the value is of the right type nor can it validate that you have passed the correct number of parameters.
Auto Trait Implementations
impl<'q, DB, R, P> RefUnwindSafe for QueryAs<'q, DB, R, P> where
P: RefUnwindSafe,
P: RefUnwindSafe,
impl<'q, DB, R, P> Send for QueryAs<'q, DB, R, P> where
P: Send,
P: Send,
impl<'q, DB, R, P> Sync for QueryAs<'q, DB, R, P> where
P: Sync,
P: Sync,
impl<'q, DB, R, P> Unpin for QueryAs<'q, DB, R, P> where
P: Unpin,
P: Unpin,
impl<'q, DB, R, P> UnwindSafe for QueryAs<'q, DB, R, P> where
P: UnwindSafe,
P: UnwindSafe,
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, DB> HasSqlType<&'_ T> for DB where
DB: HasSqlType<T>,
T: ?Sized,
[src]
DB: HasSqlType<T>,
T: ?Sized,
impl<T, DB> HasSqlType<Option<T>> for DB where
DB: HasSqlType<T>,
[src]
DB: HasSqlType<T>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,