I need to load DB configuration dynamically in Drupal 7 Can I put variable_get in settings.php to load DB settings dynamically or there is a better way.
Drupal allows you to override settings using the $conf[] array in settings.php. They will be then available via variable_get('key', 'default') in any module.

See 'defining site variables' 
and variable_get()

The pattern we use is that any defaults go into install.php. starts with:

function hottopicsnotify_install() {
  variable_set(HOTTOPICSNOTIFY_CONTENT_TYPES_VAR, 'hottopics_node_form');


Override the variables with an admin form where needed. e.g.  

function hottopics_settings($form, &amp;$form_state) {


Read using variable_get. e.g.: 

'#default_value' =&gt; variable_get(HOTTOPICSNOTIFY_EDITORIAL_CRON_KEY, ''),