How to get database credentials I am integrating code that implements its own extension of PHP's PDO class, in the same way that Drupal's DatabaseConnection does. So this code (which is various data models) needs to use this non-drupal PDO object.

This code needs DSN, username and password to access the default drupal database. I noted that $databases, defined in settings.php is not available: global $databases does not work to give me access to that data.

Is there a way to ask Drupal for this info or extract it from the default connection object?
The following works perfectly for me in devel/php

global $databases;

dpm($databases);


It should return the full array of database information: