Explicitly close the database connection
(&self)
| 483 | |
| 484 | /// Explicitly close the database connection |
| 485 | pub async fn close_by_ref(&self) -> Result<(), DbErr> { |
| 486 | match self { |
| 487 | #[cfg(feature = "sqlx-mysql")] |
| 488 | DatabaseConnection::SqlxMySqlPoolConnection(conn) => conn.close_by_ref().await, |
| 489 | #[cfg(feature = "sqlx-postgres")] |
| 490 | DatabaseConnection::SqlxPostgresPoolConnection(conn) => conn.close_by_ref().await, |
| 491 | #[cfg(feature = "sqlx-sqlite")] |
| 492 | DatabaseConnection::SqlxSqlitePoolConnection(conn) => conn.close_by_ref().await, |
| 493 | #[cfg(feature = "mock")] |
| 494 | DatabaseConnection::MockDatabaseConnection(_) => { |
| 495 | // Nothing to cleanup, we just consume the `DatabaseConnection` |
| 496 | Ok(()) |
| 497 | } |
| 498 | #[cfg(feature = "proxy")] |
| 499 | DatabaseConnection::ProxyDatabaseConnection(_) => { |
| 500 | // Nothing to cleanup, we just consume the `DatabaseConnection` |
| 501 | Ok(()) |
| 502 | } |
| 503 | DatabaseConnection::Disconnected => Err(conn_err("Disconnected")), |
| 504 | } |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | impl DatabaseConnection { |