[][src]Struct mysql_async::Stmt

pub struct Stmt<T> { /* fields omitted */ }

Prepared statement.

Methods

impl<T> Stmt<T> where
    T: ConnectionLike + Sized + 'static, 
[src]

pub fn id(&self) -> u32[src]

Returns statement identifier.

pub fn columns(&self) -> &[Column][src]

Returns statement columns.

use mysql_async::{consts::{ColumnFlags, ColumnType}, Pool};
use mysql_async::prelude::*;

#[tokio::main]
async fn main() -> Result<(), mysql_async::error::Error> {
    let pool = Pool::new(get_opts());
    let conn = pool.get_conn().await?;

    let stmt = conn.prepare("SELECT 'foo', CAST(42 AS UNSIGNED)").await?;

    let columns = stmt.columns();

    assert_eq!(columns.len(), 2);
    assert_eq!(columns[0].column_type(), ColumnType::MYSQL_TYPE_VAR_STRING);
    assert!(columns[1].flags().contains(ColumnFlags::UNSIGNED_FLAG));

    Ok(())
}

pub fn params(&self) -> &[Column][src]

Returns statement parameters.

use mysql_async::{consts::{ColumnFlags, ColumnType}, Pool};
use mysql_async::prelude::*;

#[tokio::main]
async fn main() -> Result<(), mysql_async::error::Error> {
    let pool = Pool::new(get_opts());
    let conn = pool.get_conn().await?;

    let stmt = conn.prepare("SELECT ?, ?").await?;

    assert_eq!(stmt.params().len(), 2);

    Ok(())
}

pub async fn execute<P>(
    self,
    params: P
) -> Result<QueryResult<Self, BinaryProtocol>> where
    P: Into<Params>, 
[src]

See Queryable::execute

pub async fn first<P, R>(self, params: P) -> Result<(Self, Option<R>)> where
    P: Into<Params> + 'static,
    R: FromRow
[src]

See Queryable::first

pub async fn batch<I, P>(self, params_iter: I) -> Result<Self> where
    I: IntoIterator<Item = P>,
    I::IntoIter: Send + 'static,
    Params: From<P>,
    P: 'static, 
[src]

See Queryable::batch

pub async fn close(__arg0: Self) -> Result<T>[src]

This will close statement (if it's not in the cache) and resolve to a wrapped queryable.

Trait Implementations

impl<T: Debug> Debug for Stmt<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Stmt<T> where
    T: RefUnwindSafe

impl<T> Send for Stmt<T> where
    T: Send

impl<T> Sync for Stmt<T> where
    T: Sync

impl<T> Unpin for Stmt<T> where
    T: Unpin

impl<T> UnwindSafe for Stmt<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ConnectionLike for T where
    T: ConnectionLike, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,