How to check if a database is set up in settings.php?
global $databases has been removed in favor of the preexisting static connection info management methods on the Database class.

Drupal 7

global $databases;
// Check whether we have a default connection.
$has_connection = !empty($databases['default']['default']);


Drupal 8

use Drupal\Core\Database\Database;
$has_connection = (bool) Database::getConnectionInfo('default');


More links

https://www.drupal.org/node/2176621

https://www.drupal.org/node/1951216