? 698078-improvements.patch
? includes/table.inc
Index: commands/sql/sql.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/sql/sql.drush.inc,v
retrieving revision 1.64
diff -u -p -r1.64 sql.drush.inc
--- commands/sql/sql.drush.inc	10 Nov 2010 19:47:28 -0000	1.64
+++ commands/sql/sql.drush.inc	14 Nov 2010 19:22:24 -0000
@@ -188,6 +188,10 @@ function _drush_sql_connect($db_spec = N
       $command = 'psql';
       $command .= _drush_sql_get_credentials($db_spec);
       break;
+    case 'sqlite':
+      $command = 'sqlite3 ';
+      $command .= _drush_sql_get_credentials($db_spec);
+      break;
   }
   return $command;
 }
@@ -324,6 +328,20 @@ function drush_sql_build_dump_command($t
         }
       }
       break;
+    case 'sqlite':
+      // Dumping is usually not necessary in SQLite, since all database data
+      // is stored in a single file on the filesystem which can be copied just
+      // like any other file. But it still has a use in migration purposes and
+      // building human-readable diffs and such, so let's do it anyway.
+      $exec = _drush_sql_connect();
+      // SQLite's dump command doesn't support many of the features of its
+      // Postgres or MySQL equivalents. We may be able to fake some in the
+      // future, but for now, let's just support simple dumps.
+      $exec .= ' ".dump"';
+      if ($file = drush_get_option('result-file')) {
+        $exec .= ' > '. $file;
+      }
+      break;
   }
 
   return $exec;
@@ -438,7 +456,11 @@ function drush_sql_cli() {
       $command .= _drush_sql_get_credentials();
       break;
     case 'pgsql':
-      $command = ' psql';
+      $command = 'psql ';
+      $command .= _drush_sql_get_credentials();
+      break;
+    case 'sqlite':
+      $command = 'sqlite3 ';
       $command .= _drush_sql_get_credentials();
       break;
   }
@@ -608,6 +630,13 @@ function _drush_sql_get_credentials($db_
       // Don't set the password.
       // @see http://drupal.org/node/438828
       break;
+
+    case 'sqlite':
+      // SQLite doesn't do user management, instead relying on the filesystem
+      // for that. So the only info we really need is the path to the database
+      // file, and not as a "--key=value" parameter.
+      return ' ' . $db_spec['database'];
+      break;
   }
 
   // Turn each parameter into a valid parameter string.
@@ -711,6 +740,12 @@ function drush_sql_build_exec($db_spec, 
       $exec .= ' ' . (drush_get_option('extra') ? drush_get_option('extra') : "--no-align --field-separator='\t' --pset footer=off");
       $exec .= " --file $filepath";
       break;
+    case 'sqlite':
+      $exec = 'sqlite3';
+      $exec .= ' ' . drush_get_option('extra');
+      $exec .= _drush_sql_get_credentials($db_spec);
+      $exec .= " < $filepath";
+      break;
   }
   return $exec;
 }
