Skip to content

Commit

Permalink
Update to latest sqlx in example (#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn committed Jul 17, 2023
1 parent e881bf0 commit 2d4bd9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions examples/sqlx-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
7 changes: 3 additions & 4 deletions examples/sqlx-postgres/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 2d4bd9e

Please sign in to comment.