Silverstripe 4.x Database Environment Variables?

Silverstripe Version:
4.x
Question:

In Silverstripe 4.x, how do I get DB credentials with environment variables, instead of using the .env file? For instance, in app/_config.php, I tried something like:

if (getenv('SS_DATABASE_NAME')) {
	define('SS_DATABASE_NAME',  getenv('SS_DATABASE_NAME'));
}

I’ve also tried in in app/_config.php:

use SilverStripe\Core\Environment;
Environment::setEnv('SS_DATABASE_NAME', 'mydb');

In both cases I get:
“Silverstripe Framework requires a “database” key in DB::getConfig(). Did you forget to set SS_DATABASE_NAME or SS_DATABASE_CHOOSE_NAME in your environment?”

Hey, did you manage to get this resolved.

I have a similar issue when deploying to a local host using wamp…keep getting the

“Silverstripe Framework requires a “database” key in DB::getConfig(). Did you forget to set SS_DATABASE_NAME or SS_DATABASE_CHOOSE_NAME”

Note on the host. Ive tried adding a _SS_environment.php file, tried adding a .env file with credentials and…nothing! Any help appreciated