From 5966fae7c55347053fcfcd19d00f052041ea560d Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Thu, 30 Jan 2020 03:34:09 -0800 Subject: [PATCH] README: note req. of `DATABASE_URL` for `query!()` --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b978e710..5a909f2c 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,13 @@ let countries = sqlx::query!( .await?; ``` +For this mode, the `DATABASE_URL` environment variable must be set at build time so that the macro can utilize the database +server to analyze queries and check them for correctness and record their inputs (bind parameters) and outputs (columns); the database does not have to contain any data but must have the same schema as the database you will be connecting to at runtime. For convenience, you can use [a `.env` file](https://github.com/dotenv-rs/dotenv#examples) to set `DATABASE_URL` so that you don't have to pass it every time: + +``` +DATABASE_URL=mysql://localhost/my_database +``` + See the beginnings of a [RealWorld](https://github.com/gothinkster/realworld/tree/master/api#users-for-authentication) implementation in [examples/realworld-postgres](./examples/realworld-postgres). ## Safety