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<()>
pub async fn disconnect(self) -> Result<()>
Disconnects this connection from server.
Sourcepub fn new<T: Into<Opts>>(opts: T) -> BoxFuture<'static, Result<Conn>>
pub fn new<T: Into<Opts>>(opts: T) -> BoxFuture<'static, Result<Conn>>
Returns a future that resolves to Conn
.
Sourcepub async fn from_url<T: AsRef<str>>(url: T) -> Result<Conn>
pub async fn from_url<T: AsRef<str>>(url: T) -> Result<Conn>
Returns a future that resolves to Conn
.
Sourcepub async fn reset(&mut self) -> Result<bool>
pub async fn reset(&mut self) -> Result<bool>
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<()>
pub async 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
opts
for 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<'_>>
pub async fn start_transaction( &mut self, options: TxOpts, ) -> Result<Transaction<'_>>
Starts a transaction.