[−][src]Struct c3p0_mysql::mysql::r2d2::mysql::PooledConn
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.
Methods
impl PooledConn
[src]
pub fn query<T>(&mut self, query: T) -> Result<QueryResult, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
Redirects to
Conn#query
.
pub fn first<T, U>(&mut self, query: T) -> Result<Option<U>, Error> where
T: AsRef<str>,
U: FromRow,
[src]
T: AsRef<str>,
U: FromRow,
See Conn::first
.
pub fn prepare<T>(&mut self, query: T) -> Result<Stmt, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
See Conn::prepare
.
pub fn prep_exec<A, T>(
&mut self,
query: A,
params: T
) -> Result<QueryResult, Error> where
A: AsRef<str>,
T: Into<Params>,
[src]
&mut self,
query: A,
params: T
) -> Result<QueryResult, Error> where
A: AsRef<str>,
T: Into<Params>,
See Conn::prep_exec
.
pub fn first_exec<Q, P, T>(
&mut self,
query: Q,
params: P
) -> Result<Option<T>, Error> where
P: Into<Params>,
Q: AsRef<str>,
T: FromRow,
[src]
&mut self,
query: Q,
params: P
) -> Result<Option<T>, Error> where
P: Into<Params>,
Q: AsRef<str>,
T: FromRow,
See Conn::first_exec
.
pub fn start_transaction(
&'a mut self,
consistent_snapshot: bool,
isolation_level: Option<IsolationLevel>,
readonly: Option<bool>
) -> Result<Transaction<'a>, Error>
[src]
&'a mut self,
consistent_snapshot: bool,
isolation_level: Option<IsolationLevel>,
readonly: Option<bool>
) -> Result<Transaction<'a>, Error>
Redirects to
Conn#start_transaction
pub fn as_mut(&'a mut self) -> &'a mut Conn
[src]
Gives mutable reference to the wrapped
Conn
.
pub fn as_ref(&'a self) -> &'a 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
.
Trait Implementations
impl Debug for PooledConn
[src]
impl GenericConnection for PooledConn
[src]
fn query<T>(&mut self, query: T) -> Result<QueryResult, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
fn first<T, U>(&mut self, query: T) -> Result<Option<U>, Error> where
T: AsRef<str>,
U: FromRow,
[src]
T: AsRef<str>,
U: FromRow,
fn prepare<T>(&mut self, query: T) -> Result<Stmt, Error> where
T: AsRef<str>,
[src]
T: AsRef<str>,
fn prep_exec<A, T>(&mut self, query: A, params: T) -> Result<QueryResult, Error> where
A: AsRef<str>,
T: Into<Params>,
[src]
A: AsRef<str>,
T: Into<Params>,
fn first_exec<Q, P, T>(
&mut self,
query: Q,
params: P
) -> Result<Option<T>, Error> where
P: Into<Params>,
Q: AsRef<str>,
T: FromRow,
[src]
&mut self,
query: Q,
params: P
) -> Result<Option<T>, Error> where
P: Into<Params>,
Q: AsRef<str>,
T: FromRow,
impl Drop for PooledConn
[src]
Auto Trait Implementations
impl Send for PooledConn
impl Sync for PooledConn
impl Unpin for PooledConn
impl !UnwindSafe for PooledConn
impl !RefUnwindSafe for PooledConn
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> Same<T> for T
type Output = T
Should always be Self