Database API

Connecting and Using Additional/External Databases

While many Drupal developers rely solely on using the default database/schema for their Drupal installation, there are many projects that require the use of external and non-default databases. Let's look at how we did that in Drupal 7 and then learn how to do it in Drupal 8 and beyond.

 

settings.php

 
The Old Way

In Drupal 7, in order to inform Drupal about your database, you would define the connection in settings.php in an array: