mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-28 00:00:20 +02:00
Update to latest sqlx in example (#2099)
This commit is contained in:
@@ -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"] }
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user