Notice: Undefined index: driver in Database::openConnection() when trying to connect to sqlite db In one of my modules I try to connect to one SQlite DB to copy from it the info into my MySQL DB, however after creating the db info and trying to add them into the Drupal context, I get the error Notice: Undefined index: driver in Database::openConnection()

here is my function:

function query_247($table, $conditions = array()){
  $module_path = drupal_get_path('module', 'cw_ticketing' );
  $databases['247cinema']['db1'] = array (
    'driver' =&gt; 'sqlite',
    'database' =&gt; $module_path.'/247cinema_part1.sqlite',
  );
  $databases['247cinema']['db2'] = array (
    'driver' =&gt; 'sqlite',
    'database' =&gt; $module_path.'/247cinema_part2.sqlite',
  );
  // die(var_dump($databases));
  Database::addConnectionInfo('247cinema', 'db1', $databases);
  Database::addConnectionInfo('247cinema', 'db2', $databases);
  try {
    db_set_active('247cinema');
    if (count($conditions)) {
      //some logic
    }else{
      $where_s = false;
    }

    //some logic

    db_set_active();
    return$records;
  } catch (Exception $e) {
    $msg = $e-&gt;getMessage();
    watchdog('error', $msg);
    db_set_active();
  }
}


Anyone has any idea ?
The documentation is a bit misguiding as it states that the database array should be identical to the way it is declared on the settings.php file. This is wrong! 

After digging a little bit the core module it shows that addConnectionInfo is expecting a array that defines the database and the driver.

Here is the correct implementation:

      $module_path = drupal_get_path('module', 'cw_ticketing' );
      $db1 = array (
        'database' =&gt; $module_path.'/247cinema_part1.sqlite',
        'driver' =&gt; 'sqlite',
      );
      $db2 = array (
        'database' =&gt; $module_path.'/247cinema_part2.sqlite',
        'driver' =&gt; 'sqlite',
      );
      // die(var_dump($databases));
      Database::addConnectionInfo('247', 'db1', $db1);
      Database::addConnectionInfo('247', 'db2', $db2);