Skip to content

Commit a2eceec

Browse files
authored
chore: replace dotenv with dotenvy (launchbadge#2003)
* chore: replace `dotenv` with `dotenvy` The former appears to be unmaintained and the latter is a drop-in replacement. * chore: fix all warnings
1 parent 05d64fb commit a2eceec

File tree

32 files changed

+70
-62
lines changed

32 files changed

+70
-62
lines changed

Cargo.lock

Lines changed: 15 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ futures = "0.3.19"
143143
env_logger = "0.9.0"
144144
async-std = { version = "1.10.0", features = ["attributes"] }
145145
tokio = { version = "1.15.0", features = ["full"] }
146-
dotenv = "0.15.0"
146+
dotenvy = "0.15.0"
147147
trybuild = "1.0.53"
148148
sqlx-rt = { path = "./sqlx-rt" }
149149
sqlx-test = { path = "./sqlx-test" }

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ Differences from `query()`:
376376
queries against; the database does not have to contain any data but must be the same
377377
kind (MySQL, Postgres, etc.) and have the same schema as the database you will be connecting to at runtime.
378378

379-
For convenience, you can use [a `.env` file][dotenv] to set DATABASE_URL so that you don't have to pass it every time:
379+
For convenience, you can use [a `.env` file][dotenv]<sup>1</sup> to set DATABASE_URL so that you don't have to pass it every time:
380380

381381
```
382382
DATABASE_URL=mysql://localhost/my_database
@@ -423,6 +423,9 @@ putting the following in your `Cargo.toml` (More information in the
423423
opt-level = 3
424424
```
425425

426+
<sup>1</sup> The `dotenv` crate itself appears abandoned as of [December 2021](https://github.com/dotenv-rs/dotenv/issues/74)
427+
so we now use the `dotenvy` crate instead. The file format is the same.
428+
426429
## Safety
427430

428431
This crate uses `#![forbid(unsafe_code)]` to ensure everything is implemented in 100% Safe Rust.

examples/postgres/files/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ edition = "2021"
99
anyhow = "1.0"
1010
sqlx = { path = "../../../", features = ["postgres", "offline", "runtime-tokio-native-tls"] }
1111
tokio = { version = "1.20.0", features = ["macros"]}
12-
dotenv = "0.15.0"
12+
dotenvy = "0.15.0"

examples/postgres/files/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl Display for PostWithAuthorQuery {
2828

2929
#[tokio::main]
3030
async fn main() -> anyhow::Result<()> {
31-
let pool = PgPool::connect(&dotenv::var("DATABASE_URL")?).await?;
31+
let pool = PgPool::connect(&dotenvy::var("DATABASE_URL")?).await?;
3232

3333
// we can use a tranditional wrapper around the `query!()` macro using files
3434
query_file!("queries/insert_seed_data.sql")

examples/postgres/json/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ workspace = "../../../"
66

77
[dependencies]
88
anyhow = "1.0"
9-
dotenv = "0.15.0"
9+
dotenvy = "0.15.0"
1010
futures = "0.3"
1111
serde = { version = "1", features = ["derive"] }
1212
serde_json = "1"

examples/postgres/json/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct Row {
3333
#[tokio::main]
3434
async fn main() -> anyhow::Result<()> {
3535
let args = Args::from_args_safe()?;
36-
let pool = PgPool::connect(&dotenv::var("DATABASE_URL")?).await?;
36+
let pool = PgPool::connect(&dotenvy::var("DATABASE_URL")?).await?;
3737

3838
match args.cmd {
3939
Some(Command::Add) => {

examples/postgres/mockable-todos/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ futures = "0.3"
1010
sqlx = { path = "../../../", features = ["postgres", "offline", "runtime-tokio-native-tls"] }
1111
structopt = "0.3"
1212
tokio = { version = "1.20.0", features = ["macros"]}
13-
dotenv = "0.15.0"
13+
dotenvy = "0.15.0"
1414
async-trait = "0.1.41"
1515
mockall = "0.11"

examples/postgres/mockable-todos/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use async_trait::async_trait;
2-
use dotenv;
32
use sqlx::postgres::PgPool;
43
use std::{env, io::Write, sync::Arc};
54
use structopt::StructOpt;
@@ -18,7 +17,7 @@ enum Command {
1817

1918
#[tokio::main]
2019
async fn main() -> anyhow::Result<()> {
21-
dotenv::dotenv().ok();
20+
dotenvy::dotenv().ok();
2221
let args = Args::from_args_safe()?;
2322
let pool = PgPool::connect(&env::var("DATABASE_URL")?).await?;
2423
let todo_repo = PostgresTodoRepo::new(pool);

examples/postgres/todos/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ futures = "0.3"
1010
sqlx = { path = "../../../", features = ["postgres", "offline", "runtime-tokio-native-tls"] }
1111
structopt = "0.3"
1212
tokio = { version = "1.20.0", features = ["macros"]}
13-
dotenv = "0.15.0"
13+
dotenvy = "0.15.0"

0 commit comments

Comments
 (0)