[−][src]Struct 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 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]
Redirects to
Conn#start_transaction
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]
impl Drop for PooledConn
[src]
impl Queryable for PooledConn
[src]
pub fn query_iter<T: AsRef<str>>(
&mut self,
query: T
) -> Result<QueryResult<'_, '_, '_, Text>>
[src]
&mut self,
query: T
) -> Result<QueryResult<'_, '_, '_, Text>>
pub fn prep<T: AsRef<str>>(&mut self, query: T) -> Result<Statement>
[src]
pub fn close(&mut self, stmt: Statement) -> Result<()>
[src]
pub fn exec_iter<S, P>(
&mut self,
stmt: S,
params: P
) -> Result<QueryResult<'_, '_, '_, Binary>> where
S: AsStatement,
P: Into<Params>,
[src]
&mut self,
stmt: S,
params: P
) -> Result<QueryResult<'_, '_, '_, Binary>> where
S: AsStatement,
P: Into<Params>,
pub fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>> where
Q: AsRef<str>,
T: FromRow,
[src]
Q: AsRef<str>,
T: FromRow,
pub fn query_opt<T, Q>(
&mut self,
query: Q
) -> Result<Vec<StdResult<T, FromRowError>>> where
Q: AsRef<str>,
T: FromRow,
[src]
&mut self,
query: Q
) -> Result<Vec<StdResult<T, FromRowError>>> where
Q: AsRef<str>,
T: FromRow,
pub fn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>> where
Q: AsRef<str>,
T: FromRow,
[src]
Q: AsRef<str>,
T: FromRow,
pub fn query_first_opt<T, Q>(
&mut self,
query: Q
) -> Result<Option<StdResult<T, FromRowError>>> where
Q: AsRef<str>,
T: FromRow,
[src]
&mut self,
query: Q
) -> Result<Option<StdResult<T, FromRowError>>> where
Q: AsRef<str>,
T: FromRow,
pub fn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>> where
Q: AsRef<str>,
T: FromRow,
F: FnMut(T) -> U,
[src]
Q: AsRef<str>,
T: FromRow,
F: FnMut(T) -> U,
pub fn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>> where
Q: AsRef<str>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U,
[src]
Q: AsRef<str>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U,
pub fn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U> where
Q: AsRef<str>,
T: FromRow,
F: FnMut(U, T) -> U,
[src]
Q: AsRef<str>,
T: FromRow,
F: FnMut(U, T) -> U,
pub fn query_fold_opt<T, F, Q, U>(
&mut self,
query: Q,
init: U,
f: F
) -> Result<U> where
Q: AsRef<str>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U,
[src]
&mut self,
query: Q,
init: U,
f: F
) -> Result<U> where
Q: AsRef<str>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U,
pub fn query_drop<Q>(&mut self, query: Q) -> Result<()> where
Q: AsRef<str>,
[src]
Q: AsRef<str>,
pub fn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()> where
Self: Sized,
S: AsStatement,
P: Into<Params>,
I: IntoIterator<Item = P>,
[src]
Self: Sized,
S: AsStatement,
P: Into<Params>,
I: IntoIterator<Item = P>,
pub fn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
[src]
S: AsStatement,
P: Into<Params>,
T: FromRow,
pub fn exec_opt<T, S, P>(
&mut self,
stmt: S,
params: P
) -> Result<Vec<StdResult<T, FromRowError>>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
[src]
&mut self,
stmt: S,
params: P
) -> Result<Vec<StdResult<T, FromRowError>>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
pub fn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
[src]
S: AsStatement,
P: Into<Params>,
T: FromRow,
pub fn exec_first_opt<T, S, P>(
&mut self,
stmt: S,
params: P
) -> Result<Option<StdResult<T, FromRowError>>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
[src]
&mut self,
stmt: S,
params: P
) -> Result<Option<StdResult<T, FromRowError>>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
pub fn exec_map<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F
) -> Result<Vec<U>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(T) -> U,
[src]
&mut self,
stmt: S,
params: P,
f: F
) -> Result<Vec<U>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(T) -> U,
pub fn exec_map_opt<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F
) -> Result<Vec<U>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U,
[src]
&mut self,
stmt: S,
params: P,
f: F
) -> Result<Vec<U>> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(StdResult<T, FromRowError>) -> U,
pub fn exec_fold<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F
) -> Result<U> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, T) -> U,
[src]
&mut self,
stmt: S,
params: P,
init: U,
f: F
) -> Result<U> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, T) -> U,
pub fn exec_fold_opt<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F
) -> Result<U> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U,
[src]
&mut self,
stmt: S,
params: P,
init: U,
f: F
) -> Result<U> where
S: AsStatement,
P: Into<Params>,
T: FromRow,
F: FnMut(U, StdResult<T, FromRowError>) -> U,
pub fn exec_drop<S, P>(&mut self, stmt: S, params: P) -> Result<()> where
S: AsStatement,
P: Into<Params>,
[src]
S: AsStatement,
P: Into<Params>,
Auto Trait Implementations
impl !RefUnwindSafe for PooledConn
impl Send for PooledConn
impl Sync for PooledConn
impl Unpin for PooledConn
impl !UnwindSafe for PooledConn
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,