pub struct Conn(/* private fields */);Expand description
Mysql connection.
Implementations§
Source§impl Conn
impl Conn
Sourcepub fn server_version(&self) -> (u16, u16, u16)
pub fn server_version(&self) -> (u16, u16, u16)
Returns version number reported by the server.
Sourcepub fn connection_id(&self) -> u32
pub fn connection_id(&self) -> u32
Returns connection identifier.
Sourcepub fn affected_rows(&self) -> u64
pub fn affected_rows(&self) -> u64
Returns number of rows affected by the last query.
Sourcepub fn last_insert_id(&self) -> u64
pub fn last_insert_id(&self) -> u64
Returns last insert id of the last query.
Returns zero if there was no last insert id.
Sourcepub fn info_str(&self) -> Cow<'_, str>
pub fn info_str(&self) -> Cow<'_, str>
Info, reported by the server.
Will be empty if not defined.
pub fn session_state_changes(&self) -> Result<Vec<SessionStateInfo<'_>>>
Sourcepub fn reset(&mut self) -> Result<()>
pub fn reset(&mut self) -> Result<()>
Tries to reset the connection.
This function will try to invoke COM_RESET_CONNECTION with a fall back to COM_CHANGE_USER on older servers.
§Warning
There is a long-standing bug in mysql 5.6 that kills this functionality in presence of connection attributes (see Bug #92954).
§Note
Re-executes Opts::get_init.
Sourcepub fn change_user(&mut self, opts: ChangeUserOpts) -> Result<()>
pub fn change_user(&mut self, opts: ChangeUserOpts) -> Result<()>
Executes COM_CHANGE_USER.
This might be used as an older and slower alternative to COM_RESET_CONNECTION that
works on MySql prior to 5.7.3 (MariaDb prior ot 10.2.4).
§Note
- Using non-default
optsfor a pooled connection is discouraging. - Connection options will be updated permanently.
§Warning
There is a long-standing bug in mysql 5.6 that kills this functionality in presence of connection attributes (see Bug #92954).
Sourcepub fn ping(&mut self) -> Result<(), Error>
pub fn ping(&mut self) -> Result<(), Error>
Executes COM_PING
on Conn. Return true on success or false on error.
Sourcepub fn start_transaction(&mut self, tx_opts: TxOpts) -> Result<Transaction<'_>>
pub fn start_transaction(&mut self, tx_opts: TxOpts) -> Result<Transaction<'_>>
Starts new transaction with provided options.
readonly is only available since MySQL 5.6.5.
Sourcepub fn set_local_infile_handler(&mut self, handler: Option<LocalInfileHandler>)
pub fn set_local_infile_handler(&mut self, handler: Option<LocalInfileHandler>)
Sets a callback to handle requests for local files. These are
caused by using LOAD DATA LOCAL INFILE queries. The
callback is passed the filename, and a Writeable object
to receive the contents of that file.
Specifying None will reset the handler to the one specified
in the Opts for this connection.
pub fn no_backslash_escape(&self) -> bool
Trait Implementations§
Source§impl AsMut<Conn> for PooledConn
impl AsMut<Conn> for PooledConn
Source§impl AsRef<Conn> for PooledConn
impl AsRef<Conn> for PooledConn
Source§impl Queryable for Conn
impl Queryable for Conn
Source§fn query_iter<T: AsRef<str>>(
&mut self,
query: T,
) -> Result<QueryResult<'_, '_, '_, Text>>
fn query_iter<T: AsRef<str>>( &mut self, query: T, ) -> Result<QueryResult<'_, '_, '_, Text>>
Source§fn prep<T: AsRef<str>>(&mut self, query: T) -> Result<Statement>
fn prep<T: AsRef<str>>(&mut self, query: T) -> Result<Statement>
query as a prepared statement.Source§fn close(&mut self, stmt: Statement) -> Result<()>
fn close(&mut self, stmt: Statement) -> Result<()>
Source§fn exec_iter<S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<QueryResult<'_, '_, '_, Binary>>
fn exec_iter<S, P>( &mut self, stmt: S, params: P, ) -> Result<QueryResult<'_, '_, '_, Binary>>
stmt with the given params.Source§fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>>
fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>>
Source§fn query_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Vec<StdResult<T, FromRowError>>>
fn query_opt<T, Q>( &mut self, query: Q, ) -> Result<Vec<StdResult<T, FromRowError>>>
Queryable::query but useful when you not sure what your schema is.Source§fn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>>
fn query_first<T, Q>(&mut self, query: Q) -> Result<Option<T>>
Source§fn query_first_opt<T, Q>(
&mut self,
query: Q,
) -> Result<Option<StdResult<T, FromRowError>>>
fn query_first_opt<T, Q>( &mut self, query: Q, ) -> Result<Option<StdResult<T, FromRowError>>>
Queryable::query_first but useful when you not sure what your schema is.Source§fn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
fn query_map<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
Source§fn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
fn query_map_opt<T, F, Q, U>(&mut self, query: Q, f: F) -> Result<Vec<U>>
Queryable::query_map but useful when you not sure what your schema is.Source§fn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
fn query_fold<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
Source§fn query_fold_opt<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
fn query_fold_opt<T, F, Q, U>(&mut self, query: Q, init: U, f: F) -> Result<U>
Queryable::query_fold but useful when you not sure what your schema is.Source§fn query_drop<Q>(&mut self, query: Q) -> Result<()>
fn query_drop<Q>(&mut self, query: Q) -> Result<()>
Source§fn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()>
fn exec_batch<S, P, I>(&mut self, stmt: S, params: I) -> Result<()>
Source§fn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>>
fn exec<T, S, P>(&mut self, stmt: S, params: P) -> Result<Vec<T>>
stmt and collects the first result set.Source§fn exec_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Vec<StdResult<T, FromRowError>>>
fn exec_opt<T, S, P>( &mut self, stmt: S, params: P, ) -> Result<Vec<StdResult<T, FromRowError>>>
Queryable::exec but useful when you not sure what your schema is.Source§fn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>>
fn exec_first<T, S, P>(&mut self, stmt: S, params: P) -> Result<Option<T>>
stmt and returns the first row of the first result set.Source§fn exec_first_opt<T, S, P>(
&mut self,
stmt: S,
params: P,
) -> Result<Option<StdResult<T, FromRowError>>>
fn exec_first_opt<T, S, P>( &mut self, stmt: S, params: P, ) -> Result<Option<StdResult<T, FromRowError>>>
Queryable::exec_first but useful when you not sure what your schema is.Source§fn exec_map<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
fn exec_map<T, S, P, F, U>( &mut self, stmt: S, params: P, f: F, ) -> Result<Vec<U>>
stmt and maps each row of the first result set.Source§fn exec_map_opt<T, S, P, F, U>(
&mut self,
stmt: S,
params: P,
f: F,
) -> Result<Vec<U>>
fn exec_map_opt<T, S, P, F, U>( &mut self, stmt: S, params: P, f: F, ) -> Result<Vec<U>>
Queryable::exec_map but useful when you not sure what your schema is.Source§fn exec_fold<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
fn exec_fold<T, S, P, U, F>( &mut self, stmt: S, params: P, init: U, f: F, ) -> Result<U>
stmt and folds the first result set to a single value.Source§fn exec_fold_opt<T, S, P, U, F>(
&mut self,
stmt: S,
params: P,
init: U,
f: F,
) -> Result<U>
fn exec_fold_opt<T, S, P, U, F>( &mut self, stmt: S, params: P, init: U, f: F, ) -> Result<U>
Queryable::exec_fold but useful when you not sure what your schema is.