Update to latest sqlx in example (#2099)

This commit is contained in:
David Pedersen
2023-07-17 09:38:08 +02:00
parent e881bf0aec
commit 2d4bd9e853
2 changed files with 4 additions and 6 deletions
+1 -2
View File
@@ -6,8 +6,7 @@ publish = false
[dependencies]
axum = { path = "../../axum" }
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "any", "postgres"] }
tokio = { version = "1.0", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
sqlx = { version = "0.5.10", features = ["runtime-tokio-rustls", "any", "postgres"] }
+3 -4
View File
@@ -41,7 +41,7 @@ async fn main() {
// setup connection pool
let pool = PgPoolOptions::new()
.max_connections(5)
.connect_timeout(Duration::from_secs(3))
.acquire_timeout(Duration::from_secs(3))
.connect(&db_connection_str)
.await
.expect("can't connect to database");
@@ -95,11 +95,10 @@ where
}
async fn using_connection_extractor(
DatabaseConnection(conn): DatabaseConnection,
DatabaseConnection(mut conn): DatabaseConnection,
) -> Result<String, (StatusCode, String)> {
let mut conn = conn;
sqlx::query_scalar("select 'hello world from pg'")
.fetch_one(&mut conn)
.fetch_one(&mut *conn)
.await
.map_err(internal_error)
}