mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
README: note req. of DATABASE_URL
for query!()
This commit is contained in:
parent
02075c74bd
commit
5966fae7c5
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue