function _drush_sql_connect

6.x sql.drush.inc _drush_sql_connect($db_spec = NULL)
3.x sql.drush.inc _drush_sql_connect($db_spec = NULL)
4.x sql.drush.inc _drush_sql_connect($db_spec = NULL)
5.x sql.drush.inc _drush_sql_connect($db_spec = NULL)

Command callback. Emits a connect string for mysql or pgsql.

6 calls to _drush_sql_connect()
drush_sql_build_dump_command in commands/sql/sql.drush.inc
Build a mysqldump/pg_dump/sqlite statement.
drush_sql_cli in commands/sql/sql.drush.inc
drush_sql_connect in commands/sql/sql.drush.inc
drush_sql_db_exists in commands/sql/sql.drush.inc
drush_sql_sync in commands/sql/sync.sql.inc

... See full list

File

commands/sql/sql.drush.inc, line 294
Drush sql commands

Code

function _drush_sql_connect($db_spec = NULL) {
  switch (_drush_sql_get_scheme($db_spec)) {
    case 'mysql':
      $command = 'mysql';
      if (drush_get_option('A', FALSE)) {
        $command .= ' -A';
      }
      break;
    case 'pgsql':
      $command = 'psql';
      break;
    case 'sqlite':
      $command = 'sqlite3';
      break;
    case 'sqlsrv':
      $command = 'sqlcmd';
      break;
    case 'oracle':
      // use rlwrap if available for readline support
      if ($handle = popen('rlwrap -v', 'r')) {
        $command = 'rlwrap sqlplus';
        pclose($handle);
      }
      else {
        $command = 'sqlplus';
      }
      break;
  }
  $command .= _drush_sql_get_credentials($db_spec);
  return $command;
}