pub struct MySqlAsyncConnection { /* private fields */ }Expand description
Async MySQL connection.
This connection uses asupersync’s TCP stream for non-blocking I/O
and implements the Connection trait from sqlmodel-core.
Implementations§
Source§impl MySqlAsyncConnection
impl MySqlAsyncConnection
Sourcepub async fn connect(_cx: &Cx, config: MySqlConfig) -> Outcome<Self, Error>
pub async fn connect(_cx: &Cx, config: MySqlConfig) -> Outcome<Self, Error>
Establish a new async connection to the MySQL server.
This performs the complete connection handshake asynchronously:
- TCP connection
- Receive server handshake
- Send handshake response with authentication
- Handle auth result (possibly auth switch)
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get the current connection state.
Sourcepub fn connection_id(&self) -> u32
pub fn connection_id(&self) -> u32
Get the connection ID.
Sourcepub fn server_version(&self) -> Option<&str>
pub fn server_version(&self) -> Option<&str>
Get the server version.
Sourcepub fn affected_rows(&self) -> u64
pub fn affected_rows(&self) -> u64
Get the number of affected rows from the last statement.
Sourcepub fn last_insert_id(&self) -> u64
pub fn last_insert_id(&self) -> u64
Get the last insert ID.
Sourcepub async fn query_async(
&mut self,
_cx: &Cx,
sql: &str,
params: &[Value],
) -> Outcome<Vec<Row>, Error>
pub async fn query_async( &mut self, _cx: &Cx, sql: &str, params: &[Value], ) -> Outcome<Vec<Row>, Error>
Execute a text protocol query asynchronously.
Sourcepub async fn execute_async(
&mut self,
cx: &Cx,
sql: &str,
params: &[Value],
) -> Outcome<u64, Error>
pub async fn execute_async( &mut self, cx: &Cx, sql: &str, params: &[Value], ) -> Outcome<u64, Error>
Execute a statement asynchronously and return affected rows.
This is similar to query_async but returns the number of affected rows
instead of the result set. Useful for INSERT, UPDATE, DELETE statements.
Sourcepub async fn prepare_async(
&mut self,
_cx: &Cx,
sql: &str,
) -> Outcome<PreparedStatement, Error>
pub async fn prepare_async( &mut self, _cx: &Cx, sql: &str, ) -> Outcome<PreparedStatement, Error>
Prepare a statement for later execution using the binary protocol.
This sends COM_STMT_PREPARE to the server and stores the metadata
needed for later execution via query_prepared_async or execute_prepared_async.
Sourcepub async fn query_prepared_async(
&mut self,
_cx: &Cx,
stmt: &PreparedStatement,
params: &[Value],
) -> Outcome<Vec<Row>, Error>
pub async fn query_prepared_async( &mut self, _cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> Outcome<Vec<Row>, Error>
Execute a prepared statement and return result rows (binary protocol).
Sourcepub async fn execute_prepared_async(
&mut self,
cx: &Cx,
stmt: &PreparedStatement,
params: &[Value],
) -> Outcome<u64, Error>
pub async fn execute_prepared_async( &mut self, cx: &Cx, stmt: &PreparedStatement, params: &[Value], ) -> Outcome<u64, Error>
Execute a prepared statement and return affected row count.
Sourcepub async fn close_prepared_async(&mut self, stmt: &PreparedStatement)
pub async fn close_prepared_async(&mut self, stmt: &PreparedStatement)
Close a prepared statement.