Skip to main content

MysqlConnection

Struct MysqlConnection 

Source
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: Conn

Implementations§

Source§

impl MysqlConnection

Source

pub fn from_conn(conn: Conn) -> Self

Wrap an existing mysql::Conn.

Methods from Deref<Target = Conn>§

Source

pub fn server_version(&self) -> (u16, u16, u16)

Returns version number reported by the server.

Source

pub fn connection_id(&self) -> u32

Returns connection identifier.

Source

pub fn affected_rows(&self) -> u64

Returns number of rows affected by the last query.

Source

pub fn last_insert_id(&self) -> u64

Returns last insert id of the last query.

Returns zero if there was no last insert id.

Source

pub fn warnings(&self) -> u16

Returns number of warnings, reported by the server.

Source

pub fn info_ref(&self) -> &[u8]

Info, reported by the server.

Will be empty if not defined.

Source

pub fn info_str(&self) -> Cow<'_, str>

Info, reported by the server.

Will be empty if not defined.

Source

pub fn session_state_changes(&self) -> Result<Vec<SessionStateInfo<'_>>, Error>

Source

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.

Source

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 opts for 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).

Source

pub fn ping(&mut self) -> Result<(), Error>

Executes COM_PING on Conn. Return true on success or false on error.

Source

pub fn select_db(&mut self, schema: &str) -> Result<(), Error>

Executes COM_INIT_DB on Conn.

Source

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.

Source

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.

Source

pub fn no_backslash_escape(&self) -> bool

Trait Implementations§

Source§

impl ComposerConnection for MysqlConnection

Available on crate feature sync only.
Source§

type Value = Value

The database-specific value type for bind parameters. Read more
Source§

type Statement = String

The composed SQL string (callers use this to prepare statements).
Source§

type Error = SyncError

The error type for this driver.
Source§

fn compose( &self, composer: &Composer, template: &Template, values: BTreeMap<String, Vec<Self::Value>>, ) -> Result<(String, Vec<Self::Value>), SyncError>

Compose a template with bind values, returning prepared SQL and ordered values. Read more
Source§

impl Deref for MysqlConnection

Available on crate feature sync only.
Source§

type Target = Conn

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for MysqlConnection

Available on crate feature sync only.
Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V