pub struct MysqlConnection(pub Conn);Expand description
A wrapper around mysql::Conn that implements sql_composer::driver::ComposerConnection.
Dereferences to the inner mysql::Conn, so all native sync methods
are available directly.
Tuple Fields§
§0: ConnImplementations§
Methods from Deref<Target = 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<'_>>, Error>
Sourcepub fn reset(&mut self) -> Result<(), Error>
pub fn reset(&mut self) -> Result<(), Error>
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<(), Error>
pub fn change_user(&mut self, opts: ChangeUserOpts) -> Result<(), Error>
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<'_>, Error>
pub fn start_transaction( &mut self, tx_opts: TxOpts, ) -> Result<Transaction<'_>, Error>
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 ComposerConnection for MysqlConnection
Available on crate feature sync only.
impl ComposerConnection for MysqlConnection
sync only.Source§impl Deref for MysqlConnection
Available on crate feature sync only.
impl Deref for MysqlConnection
sync only.