Struct mysql_macro::Conn
source · pub struct Conn { /* private fields */ }Expand description
MySql server connection.
Implementations§
source§impl Conn
impl 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 disconnect(self) -> Result<(), Error>
pub async fn disconnect(self) -> Result<(), Error>
Disconnects this connection from server.
sourcepub fn new<T>(
opts: T
) -> Pin<Box<dyn Future<Output = Result<Conn, Error>> + Send>>
pub fn new<T>( opts: T ) -> Pin<Box<dyn Future<Output = Result<Conn, Error>> + Send>>
Returns a future that resolves to Conn.
sourcepub async fn from_url<T>(url: T) -> Result<Conn, Error>
pub async fn from_url<T>(url: T) -> Result<Conn, Error>
Returns a future that resolves to Conn.
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.
source§impl Conn
impl Conn
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 Queryable for Conn
impl Queryable for Conn
source§fn ping(
&mut self
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
fn ping( &mut self ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + '_>>
COM_PING.