I need help to read database connection string from .env file
rocket docs suggests the connection is set in Rocket.toml file. I found a post stackoverflow with same problem But the solution is implemented for Rocket v0.4x and I am using version 0.5-rc
Are you thinking of the
the dotenv crate? It lets you set
ROCKET_DATABASES and other environment variables in a file named
Not really, my application is Dockerized, I want to be able to pass the Database connection string in when running the app rather than setting it in Rocket.toml
Tae a look at
Figment. Its documentation is pretty clear on how to read a config value from an environment variable. Plus it's from the creator of Rocket, so I assume that Rocket is using it as its config library.
You might consider using the
Luca Palmieri has a
tutorial on setting up a database connection using the
config crate in the book Zero to Production in Rust.
October 11, 2022, 6:49am
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.