I have database connected to my discord bot through .env and dotenvy crate. I'm using sqlx with sqlite and db url is the same directory as root dir, but my app can access this info ONLY through env file or env var.
I'm using nssm to create a service for ds bot to run there without needing terminal opened. I didnt configure it and don't even know how if its even possible. In regedit i didn't change anything for my service and also there is no .env file in root directory where my executable located, but somehow my bot still works, db works as well.
yeah, that's good to know. Thanks
But still don't know how my app gets its connection string for db.
To be clear i didn't configure anything outside of my app, and inside of it there is only env file with db conn in it, but in exe enviroment there is no .env file
No, dotenvy::dotenv reads the environment file during run time. Note that it reads .env files in the working directory and all the parent directories. By calling ok(), we never actually know if dotenvy found an environment file or if the program's environment contained the correct variables without being able to read an environment file. The result of a successful call to dotenv returns the path of the environment file. You could print it to see what dotenvy finds (or in case the call returns an io::ErrorKind::NotFound error, we know that no file was found).