Struct mysql::PooledConn [] [src]

pub struct PooledConn {
    // some fields omitted
}

Pooled mysql connection which will return to the pool on drop.

You should prefer using prepare or prep_exec instead of query where possible, except cases when statement has no params and when it has no return values or return values which evaluates to Value::Bytes.

query is a part of mysql text protocol, so under the hood you will always receive Value::Bytes as a result and from_value will need to parse it if you want, for example, i64

let mut conn = pool.get_conn().unwrap();

conn.query("SELECT 42").map(|mut result| {
    let cell = result.next().unwrap().unwrap().take(0).unwrap();
    assert_eq!(cell, Value::Bytes(b"42".to_vec()));
    assert_eq!(from_value::<i64>(cell), 42i64);
});
conn.prep_exec("SELECT 42", ()).map(|mut result| {
    let cell = result.next().unwrap().unwrap().take(0).unwrap();
    assert_eq!(cell, Value::Int(42i64));
    assert_eq!(from_value::<i64>(cell), 42i64);
});

For more info on how to work with query results please look at QueryResult documentation.

Methods

impl PooledConn

fn query<'a, T: AsRef<str> + 'a>(&'a mut self, query: T) -> MyResult<QueryResult<'a>>

Redirects to Conn#query.

fn prepare<'a, T: AsRef<str> + 'a>(&'a mut self, query: T) -> MyResult<Stmt<'a>>

Redirects to Conn#prepare.

fn prep_exec<'a, A, T>(&'a mut self, query: A, params: T) -> MyResult<QueryResult<'a>> where A: AsRef<str> + 'a, T: Into<Params>

Redirects to Conn#prep_exec.

fn start_transaction<'a>(&'a mut self, consistent_snapshot: bool, isolation_level: Option<IsolationLevel>, readonly: Option<bool>) -> MyResult<Transaction<'a>>

fn as_mut<'a>(&'a mut self) -> &'a mut Conn

Gives mutable reference to the wrapped Conn.

fn as_ref<'a>(&'a self) -> &'a Conn

Gives reference to the wrapped Conn.

fn unwrap(self) -> Conn

Unwraps wrapped Conn.

Trait Implementations

impl Drop for PooledConn

fn drop(&mut self)

Derived Implementations

impl Debug for PooledConn

fn fmt(&self, __arg_0: &mut Formatter) -> Result