Drupal uses a lightweight database abstraction layer between the code and the database.
In the sites/all/settings.php file.
Database Abstraction Layer
Drupal determines the type of database to connect to by inspecting the $db_url variable inside settings.php.
Connecting to the Database
Drupal connects to the database as part of its normal bootstrap process.
Function db_query() is used to execute a query.