The query is within `get_all_products` in the following code:

```rust
struct Product {
    name: String,
    price: f32
}

async fn get_all_products(conn: impl sqlx::Executor) -> sqlx::Result<Vec<Product>> {
    sqlx::query_as!(Product, "select (name, price) from products")
        .fetch_all(&mut conn)
        .await
}
```

This query expects the database to contain a table `products` with the products, and 2 rows `name` and `price` with their name and price respectively. `conn` represents your database connection, which you can get a variety of ways, the most straightforward being `AnyConnection::connect("postgres://postgres@my/url").await?`

Be aware that this query will fetch and store *all* product names and prices, which may waste time and resources if the table is very large and/or you only need some of them. The following variant will stream the results so you can process one at a time and stop before fetching them all.

```rust
fn get_all_products(conn: impl sqlx::Executor) -> impl Stream<sqlx::Result<Product>> {
    sqlx::query_as!(Product, "select (name, price) from products")
        .fetch(&mut conn)
}
```

For more info, see https://docs.rs/sqlx/latest/sqlx
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence