How do I import a database through a Drush(PHP) script?
Basically, you want to run some php code to import an SQL database dump from a file.  There is code that does this in the implementation of drush sql-sync.  It looks like this:

  $options = $global_options + $target_options + array(
    'file' =&gt; $destination_dump_path,
    'file-delete' =&gt; TRUE,
  );
  $return = drush_invoke_process($destination, 'sql-query', array(), $options, $backend_options);
  if ($return['error_status']) {
    // An error was already logged.
    return FALSE;
  }


You could also call drush sql-sync with appropriate options for a more full-featured solution (e.g. if you want to import a local database to a remote site).  For an import to a local site, though, it is more straightforward to simply use the snippet above, which essentially runs drush sql-query --file=/path/to/dump.sql.

n.b. You may simply remove (or make empty) $global_options, $target_options and $backend_options. You should also take of the file-delete flag, unless you really would like Drush to delete your sql dump for you after it has imported it (e.g. for temporary files).