I am looking for a way to change the database connection in the settings.php file, through command line.
I was wondering if there was an api-call or drush method which would allow me to do this. An option off course is do use grep and replace parts of the string.
Hope anyone could point me in the right direction. Thanks in advance!

Comments

The only way I know to do

The only way I know to do that is to edit the file.

Didn't find any drush /

Didn't find any drush / drupal api possibility, so ended out with sed. Just sharing here ;-)

dbstring="'default' => array('default' => array('database' => '******', 'username' => '*****', 'password' => '******', 'host' => 'localhost', 'port' => '', 'driver' => 'mysql', 'prefix' => '' ) ), "
sed "s/\$databases = array();/\$databases = array( $dbstring );/" ../sites/default/default.settings.php > ../sites/default/settings.php
nobody click here