[−][src]Struct sqlx::Query
Dynamic SQL query with bind parameters. Returned by [query].
The methods on this struct should be passed a reference to crate::Pool or one of the connection types.
Methods
impl<'q, DB, P> Query<'q, DB, P> where
DB: Database,
P: IntoArguments<DB> + Send,
[src]
DB: Database,
P: IntoArguments<DB> + Send,
pub async fn execute<E>(self, executor: &'_ mut E) -> Result<u64, Error> 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.
pub fn fetch<'e, E>(
self,
executor: &'e mut E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
E: Executor<Database = DB>,
[src]
self,
executor: &'e mut E
) -> Pin<Box<dyn Stream<Item = Result<<DB as Database>::Row, Error>> + 'e + Send>> where
'q: 'e,
E: Executor<Database = DB>,
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<<DB as Database>::Row>, Error> where
E: Executor<Database = DB>,
[src]
self,
executor: &'_ mut E
) -> Result<Vec<<DB as Database>::Row>, Error> where
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<<DB as Database>::Row>, Error> where
E: Executor<Database = DB>,
[src]
self,
executor: &'_ mut E
) -> Result<Option<<DB as Database>::Row>, Error> 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<<DB as Database>::Row, Error> where
E: Executor<Database = DB>,
[src]
self,
executor: &'_ mut E
) -> Result<<DB as Database>::Row, Error> where
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> Query<'q, DB, <DB as Database>::Arguments> where
DB: Database,
[src]
DB: Database,
pub fn bind<T>(self, value: T) -> Query<'q, DB, <DB as Database>::Arguments> 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, T> RefUnwindSafe for Query<'q, DB, T> where
DB: RefUnwindSafe,
T: RefUnwindSafe,
DB: RefUnwindSafe,
T: RefUnwindSafe,
impl<'q, DB, T> Send for Query<'q, DB, T> where
DB: Send,
T: Send,
DB: Send,
T: Send,
impl<'q, DB, T> Sync for Query<'q, DB, T> where
DB: Sync,
T: Sync,
DB: Sync,
T: Sync,
impl<'q, DB, T> Unpin for Query<'q, DB, T> where
DB: Unpin,
T: Unpin,
DB: Unpin,
T: Unpin,
impl<'q, DB, T> UnwindSafe for Query<'q, DB, T> where
DB: UnwindSafe,
T: UnwindSafe,
DB: UnwindSafe,
T: 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> 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>,