[][src]Struct mysql::PooledConn

pub struct PooledConn { /* 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 pool = Pool::new(get_opts()).unwrap();
let mut conn = pool.get_conn().unwrap();

conn.query_first("SELECT 42").map(|result: Option<Value>| {
    let result = result.unwrap();
    assert_eq!(result, Value::Bytes(b"42".to_vec()));
    assert_eq!(from_value::<i64>(result), 42i64);
}).unwrap();
conn.exec_iter("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);
}).unwrap();

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

Implementations

impl PooledConn[src]

pub fn start_transaction(&mut self, tx_opts: TxOpts) -> Result<Transaction<'_>>[src]

pub fn as_mut(&mut self) -> &mut Conn[src]

Gives mutable reference to the wrapped Conn.

pub fn as_ref(&self) -> &Conn[src]

Gives reference to the wrapped Conn.

pub fn unwrap(self) -> Conn[src]

Unwraps wrapped Conn.

pub fn set_local_infile_handler(&mut self, handler: Option<LocalInfileHandler>)[src]

A way to override default local infile handler for this pooled connection. Destructor will restore original handler before returning connection to a pool. See Conn::set_local_infile_handler.

Methods from Deref<Target = Conn>

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

Returns connection identifier.

pub fn affected_rows(&self) -> u64[src]

Returns number of rows affected by the last query.

pub fn last_insert_id(&self) -> u64[src]

Returns last insert id of the last query.

Returns zero if there was no last insert id.

pub fn warnings(&self) -> u16[src]

Returns number of warnings, reported by the server.

pub fn info_ref(&self) -> &[u8][src]

Info, reported by the server.

Will be empty if not defined.

pub fn info_str(&self) -> Cow<'_, str>[src]

Info, reported by the server.

Will be empty if not defined.

pub fn no_backslash_escape(&self) -> bool[src]

Trait Implementations

impl Debug for PooledConn[src]

impl Deref for PooledConn[src]

type Target = Conn

The resulting type after dereferencing.

impl Drop for PooledConn[src]

impl Queryable for PooledConn[src]

Auto Trait Implementations

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> 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>,