pub struct Query<'a> { /* private fields */ }Expand description
A prepared query returning untyped crate::Rows.
Implementations§
Source§impl<'a> Query<'a>
impl<'a> Query<'a>
Sourcepub fn new(sql: &'a str, params: &'a [&'a dyn ToSql]) -> Self
pub fn new(sql: &'a str, params: &'a [&'a dyn ToSql]) -> Self
Builds a query from SQL and already-built parameters.
Sourcepub async fn execute<E: Executor>(&self, executor: &E) -> Result<u64, Error>
pub async fn execute<E: Executor>(&self, executor: &E) -> Result<u64, Error>
Runs the statement and returns the number of affected rows.
Use this for statements that change data (INSERT, UPDATE, DELETE,
DDL). Any rows the statement produces are read and discarded; the
returned count is the command tag’s affected-row count (for example the
number of inserted or updated rows).
§Errors
Returns a server error if the statement fails, or Error::Closed if
the connection is gone.
Sourcepub async fn fetch_rows<E: Executor>(
&self,
executor: &E,
) -> Result<RowStream, Error>
pub async fn fetch_rows<E: Executor>( &self, executor: &E, ) -> Result<RowStream, Error>
Runs the statement and returns a stream of rows.
Sourcepub async fn fetch_all<E: Executor, T: FromRow>(
&self,
executor: &E,
) -> Result<Vec<T>, Error>
pub async fn fetch_all<E: Executor, T: FromRow>( &self, executor: &E, ) -> Result<Vec<T>, Error>
Collects all rows into a Vec<T>.
The result is unbounded: use Query::fetch_rows to process a large
result without holding it all in memory.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Query<'a>
impl<'a> !UnwindSafe for Query<'a>
impl<'a> Freeze for Query<'a>
impl<'a> Send for Query<'a>
impl<'a> Sync for Query<'a>
impl<'a> Unpin for Query<'a>
impl<'a> UnsafeUnpin for Query<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more