There is no WordPress action hook that runs before the database connection is made. But you can execute custom code by:
Placing it early in wp-config.php, before the require_once wp-settings.php; line.
wp-config.php
require_once wp-settings.php;