From sqlx pool
This commit is contained in:
parent
9beca86617
commit
398e1f0913
@ -22,9 +22,9 @@ impl Connector for SqlxMySqlConnector {
|
||||
}
|
||||
|
||||
async fn connect(string: &str) -> Result<DatabaseConnection, ConnectionErr> {
|
||||
if let Ok(conn) = MySqlPool::connect(string).await {
|
||||
if let Ok(pool) = MySqlPool::connect(string).await {
|
||||
Ok(DatabaseConnection::SqlxMySqlPoolConnection(
|
||||
SqlxMySqlPoolConnection { pool: conn },
|
||||
SqlxMySqlPoolConnection { pool },
|
||||
))
|
||||
} else {
|
||||
Err(ConnectionErr)
|
||||
@ -32,6 +32,14 @@ impl Connector for SqlxMySqlConnector {
|
||||
}
|
||||
}
|
||||
|
||||
impl SqlxMySqlConnector {
|
||||
pub fn from_sqlx_mysql_pool(pool: MySqlPool) -> DatabaseConnection {
|
||||
DatabaseConnection::SqlxMySqlPoolConnection(
|
||||
SqlxMySqlPoolConnection { pool },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Connection for &SqlxMySqlPoolConnection {
|
||||
async fn execute(&self, stmt: Statement) -> Result<ExecResult, ExecErr> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user