8 – Multiple databases – Drupal Answers

I’m having trouble getting Drupal to switch between multiple databases. I have a system that involves connecting to an external database to retrieve data. I am using the following code inside of a form at build time to get some information for displaying in the form.

$connExternal = DrupalCoreDatabaseDatabase::getConnection('default', 'atavism');
$results = $connExternal->select('world');
$data = $results->query();

$result = $data->fetchAll();


However, when I visit the form, Drupal redirects me back to the install page, where it tells me that drupal is already installed. I have tried using setActiveConnection() as well, but the same thing keeps happening. I am not sure how to resolve it, and access the secondary database for retrieving the information I need.

Inside of my settings.php, I have this:

$databases('atavism')('default') = array (
  'database' => 'world',
  'username' => 'redacted',
  'password' => 'redacted',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\Core\Database\Driver\mysql',
  'driver' => 'mysql',

Am I missing something?