Struct mysql::PooledConn

source ·
pub struct PooledConn { /* private fields */ }
Expand description

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);
}).unwrap();
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);
}).unwrap();

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

Implementations§

Redirects to Conn#query.

Gives mutable reference to the wrapped Conn.

Gives reference to the wrapped Conn.

Unwraps wrapped Conn.

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.

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.