Query Postgres from Axum
In an empty directory, createsrc and save these two files. The handler uses a runtime SQL query, so the image builds without a database. Each running instance shares one pool of up to four connections.
Cargo.toml
src/main.rs
Build the image and run the migration
Dockerfile
floo.app.toml
axum-pickup- in floo.app.toml. floo runs /axum-pickup-api migrate with the new image before it receives traffic. On later deploys, existing order statuses survive the migration. Dev and prod have separate databases.
From the example directory with Rust 1.97, the floo CLI, and a floo sign-in:
Check the first response
Open the dev URL printed by the deploy. The root path returns HTTP 200 with:query! macros, generate SQLx offline metadata against your development schema and commit it before building the image. See SQLx offline builds and connecting to managed Postgres.