pub struct MySqlConnection { /* private fields */ }
Expand description
A MySQL connection using mysql-async
Implementations§
Source§impl MySqlConnection
impl MySqlConnection
Sourcepub async fn connect(connection_string: String) -> Result<Self, MySqlError>
pub async fn connect(connection_string: String) -> Result<Self, MySqlError>
Create a new connection to the database
Sourcepub async fn query_drop<Q: AsRef<str>>(
&self,
query: Q,
) -> Result<(), MySqlError>
pub async fn query_drop<Q: AsRef<str>>( &self, query: Q, ) -> Result<(), MySqlError>
Execute a query directly
Sourcepub async fn exec_drop<Q: AsRef<str>, P: Into<Params> + Send>(
&self,
query: Q,
params: P,
) -> Result<(), MySqlError>
pub async fn exec_drop<Q: AsRef<str>, P: Into<Params> + Send>( &self, query: Q, params: P, ) -> Result<(), MySqlError>
Execute a parameterized query directly
Sourcepub async fn begin_transaction(&self) -> Result<MySqlTransaction, MySqlError>
pub async fn begin_transaction(&self) -> Result<MySqlTransaction, MySqlError>
Start a transaction
Sourcepub fn connection_string(&self) -> &str
pub fn connection_string(&self) -> &str
Get the connection string
Sourcepub async fn query_map<T, F, Q>(
&self,
query: Q,
f: F,
) -> Result<Vec<T>, MySqlError>
pub async fn query_map<T, F, Q>( &self, query: Q, f: F, ) -> Result<Vec<T>, MySqlError>
Execute a query and map the results
Sourcepub async fn query_first<T: FromRow + Send + 'static, Q: AsRef<str>>(
&self,
query: Q,
) -> Result<T, MySqlError>
pub async fn query_first<T: FromRow + Send + 'static, Q: AsRef<str>>( &self, query: Q, ) -> Result<T, MySqlError>
Execute a query and return the first result
Sourcepub async fn select_database(
&self,
database_name: &str,
) -> Result<(), MySqlError>
pub async fn select_database( &self, database_name: &str, ) -> Result<(), MySqlError>
Select a specific database
Trait Implementations§
Source§impl Clone for MySqlConnection
impl Clone for MySqlConnection
Source§fn clone(&self) -> MySqlConnection
fn clone(&self) -> MySqlConnection
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl TestDatabaseConnection for MySqlConnection
impl TestDatabaseConnection for MySqlConnection
fn connection_string(&self) -> String
Auto Trait Implementations§
impl Freeze for MySqlConnection
impl !RefUnwindSafe for MySqlConnection
impl Send for MySqlConnection
impl Sync for MySqlConnection
impl Unpin for MySqlConnection
impl !UnwindSafe for MySqlConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more