pub struct MysqlConn(pub Conn);Expand description
A wrapper around mysql_async::Conn that implements sql_composer::driver::ComposerConnectionAsync.
Dereferences to the inner mysql_async::Conn, so all native async
methods are available directly.
Tuple Fields§
§0: ConnImplementations§
Methods from Deref<Target = Conn>§
Sourcepub fn last_insert_id(&self) -> Option<u64>
pub fn last_insert_id(&self) -> Option<u64>
Returns the ID generated by a query (usually INSERT) on a table with a column having the
AUTO_INCREMENT attribute. Returns None if there was no previous query on the connection
or if the query did not update an AUTO_INCREMENT value.
Sourcepub fn affected_rows(&self) -> u64
pub fn affected_rows(&self) -> u64
Returns the number of rows affected by the last INSERT, UPDATE, REPLACE or DELETE
query.
Sourcepub fn info(&self) -> Cow<'_, str>
pub fn info(&self) -> Cow<'_, str>
Text information, as reported by the server in the last OK packet, or an empty string.
Sourcepub fn get_warnings(&self) -> u16
pub fn get_warnings(&self) -> u16
Number of warnings, as reported by the server in the last OK packet, or 0.
Sourcepub fn last_ok_packet(&self) -> Option<&OkPacket<'static>>
pub fn last_ok_packet(&self) -> Option<&OkPacket<'static>>
Returns a reference to the last OK packet.
Sourcepub fn reset_connection(&mut self, reset_connection: bool)
pub fn reset_connection(&mut self, reset_connection: bool)
Turns on/off automatic connection reset (see crate::PoolOpts::with_reset_connection).
Only makes sense for pooled connections.
Sourcepub fn server_version(&self) -> (u16, u16, u16)
pub fn server_version(&self) -> (u16, u16, u16)
Returns server version.
Sourcepub fn set_infile_handler<T>(&mut self, handler: T)
pub fn set_infile_handler<T>(&mut self, handler: T)
Setup local LOCAL INFILE handler (see “LOCAL INFILE Handlers” section
of the crate-level docs).
It’ll overwrite existing local handler, if any.
Sourcepub async fn reset(&mut self) -> Result<bool, Error>
pub async fn reset(&mut self) -> Result<bool, Error>
Executes COM_RESET_CONNECTION.
Returns false if command is not supported (requires MySql >5.7.2, MariaDb >10.2.3).
For older versions consider using Conn::change_user.
Sourcepub async fn change_user(&mut self, opts: ChangeUserOpts) -> Result<(), Error>
pub async 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 permanently updated.
Sourcepub async fn start_transaction(
&mut self,
options: TxOpts,
) -> Result<Transaction<'_>, Error>
pub async fn start_transaction( &mut self, options: TxOpts, ) -> Result<Transaction<'_>, Error>
Starts a transaction.
Trait Implementations§
Source§impl ComposerConnectionAsync for MysqlConn
Available on crate feature async only.
impl ComposerConnectionAsync for MysqlConn
async only.