Skip to content

Commit feaa86d

Browse files
committed
Update to latest sqlx in example (#2099)
1 parent fd54d1a commit feaa86d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

examples/sqlx-postgres/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ publish = false
66

77
[dependencies]
88
axum = { path = "../../axum" }
9+
sqlx = { version = "0.7", features = ["runtime-tokio-rustls", "any", "postgres"] }
910
tokio = { version = "1.0", features = ["full"] }
1011
tracing = "0.1"
1112
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
12-
13-
sqlx = { version = "0.5.10", features = ["runtime-tokio-rustls", "any", "postgres"] }

examples/sqlx-postgres/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn main() {
4141
// setup connection pool
4242
let pool = PgPoolOptions::new()
4343
.max_connections(5)
44-
.connect_timeout(Duration::from_secs(3))
44+
.acquire_timeout(Duration::from_secs(3))
4545
.connect(&db_connection_str)
4646
.await
4747
.expect("can't connect to database");
@@ -95,11 +95,10 @@ where
9595
}
9696

9797
async fn using_connection_extractor(
98-
DatabaseConnection(conn): DatabaseConnection,
98+
DatabaseConnection(mut conn): DatabaseConnection,
9999
) -> Result<String, (StatusCode, String)> {
100-
let mut conn = conn;
101100
sqlx::query_scalar("select 'hello world from pg'")
102-
.fetch_one(&mut conn)
101+
.fetch_one(&mut *conn)
103102
.await
104103
.map_err(internal_error)
105104
}

0 commit comments

Comments
 (0)