Quantcast
Channel: How to set up a database connection from environment in Rocket? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How to set up a database connection from environment in Rocket?

$
0
0

I have following working database connection setup for my Rocket app:

main.rs:

#[database("my_db")]pub struct DbConn(diesel::PgConnection);

Rocket.toml:

[global.databases]my_db = { url = "postgres://user:pass@localhost/my_db" }

I would like to set username, password and a database name from the environment. Expected it to be something like ROCKET_MY_DB=postgres://user:pass@localhost/my_db, but it didn't work. Was unable find relevant database example for Rocket.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images