Dump the production DB.
179942
def dump_prod id
      target_path = File.expand_path("../../fixtures/trunk-#{id}.dump", __FILE__)
      puts "Dumping production database from Heroku (works only if you have access to the database)"
      command = "curl -o #{target_path} \`heroku pg:backups public-url #{id} -a cocoapods-trunk-service\`"
      puts "Executing command:"
      puts command
      result = system command
      if result
        puts "Production database snapshot #{id} dumped into #{target_path}"
      else
        raise "Could not dump #{id} from production database."
      end
    end
718903
def pg_dump(db_name, backup_path):
    """"""

    logger.info("Dumping %s to %s", repr(db_name), repr(backup_path))
    return shell(
        'pg_dump "{db_name}" -U "{USER}" -h "{HOST}" '
        "--schema=public --file={backup_path}".format(
            db_name=db_name, backup_path=backup_path, **DB
        )
    )
975364
public function dump()
	{
		$pdo = $this->pdo();

		$sql = '';

		foreach ($this->list_tables() as $table)
		{
			$query = $pdo->query("SELECT * FROM `{$table}`");

			while ($row = $query->fetch(\PDO::FETCH_NUM)) 
			{
				$values = array();

				foreach ($row as $column) 
				{
					$values[] = is_null($column) ? 'NULL' : $pdo->quote($column);
				}

				$sql .= "INSERT INTO `{$table}` VALUES (".join(',', $values). ");\n";
			}
		}

		return $sql;
	}
748192
public static void dump(DataSource dataSource, PrintStream out) {
    try (Log log = Log.create(out)) {
      log.write(CallInfo.create(), executeQuery(dataSource));
    }
  }
146493
def dumps(self):
        """"""
        self.data.update({
            'bucket': str(self.obj.bucket_id),
            'checksum': self.obj.file.checksum,
            'key': self.obj.key,  # IMPORTANT it must stay here!
            'size': self.obj.file.size,
            'version_id': str(self.obj.version_id),
        })
        return self.data
753322
static void dumpAll(Printer printer, boolean verbose) {
        for (SQLiteDatabase db : getActiveDatabases()) {
            db.dump(printer, verbose);
        }
    }
412513
def dump(
    state, host,
    remote_filename, database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None, mysql_password=None,
    mysql_host=None, mysql_port=None,
):
    '''
    
    '''

    yield '{0} > {1}'.format(make_mysql_command(
        executable='mysqldump',
        database=database,
        user=mysql_user,
        password=mysql_password,
        host=mysql_host,
        port=mysql_port,
    ), remote_filename)
1338217
def dump(self, backend, node):
        ''''''
        assert issubclass(backend, Backend)
        b = backend()
        b.attach(self)
        return b.run(node)
474211
def dump(db, path)
      Mongolicious.logger.info("Dumping database #{db[:db]}")

      cmd = "mongodump -d #{db[:db]} -h #{db[:host]}:#{db[:port]} -o #{path}"
      cmd << " -u '#{db[:user]}' -p '#{db[:password]}'" unless (db[:user].nil? || db[:user].empty?)
      cmd << " > /dev/null"

      system(cmd)
      raise "Error while backuing up #{db[:db]}" if $?.to_i != 0
    end
470092
protected function dumpCurrentDB()
    {
        date_default_timezone_set("Etc/UTC");
        $relativeFilename = sprintf("export_%s_%s.sql", date('Y-m-d'), time());
        $command = sprintf("%s db export %s%s --add-drop-table", $this->getWpCliPath(), Strata::getDbPath(), $relativeFilename);
        $this->output->writeLn("Generating MySQL export dump to ./$relativeFilename");
        system($command);
    }
23238
public void dump() throws IOException {
    FileWriter out = new FileWriter(outFile, true);
    try {
      dump(out);
    } finally {
      out.close();
    }
  }
304663
def save(self, output=None):
        
        if output is None:
            if self.dbfile is None:
                return
            output = self.dbfile

        with open(output, 'w') as f:
            f.write(self._dump())
430545
def dump2sqlite(records, output_file):
    """"""
    results_keys = list(records.results[0].keys())
    pad_data = []

    for key in REQUIRED_KEYS:
        if key not in results_keys:
            results_keys.append(key)
            pad_data.append("")

    conn = sqlite3.connect(os.path.expanduser(output_file), detect_types=sqlite3.PARSE_DECLTYPES)

    # in each row there needs to be data for every column
    # last column is current time
    pad_data.append(datetime.datetime.utcnow())

    to_db = [list(row.values()) + pad_data for row in records.results]

    cur = conn.cursor()
    cur.execute(
        "CREATE TABLE testcases ({},sqltime TIMESTAMP)".format(
            ",".join("{} TEXT".format(key) for key in results_keys)
        )
    )
    cur.executemany(
        "INSERT INTO testcases VALUES ({},?)".format(",".join(["?"] * len(results_keys))), to_db
    )

    if records.testrun:
        cur.execute("CREATE TABLE testrun (testrun TEXT)")
        cur.execute("INSERT INTO testrun VALUES (?)", (records.testrun,))

    conn.commit()
    conn.close()

    logger.info("Data written to '%s'", output_file)
1040066
def _Close(self):
    """"""
    if self._database_object:
      self._database_object.Close()

    self._blob = None
    self._current_offset = 0
    self._size = 0
    self._table_name = None
1046401
def wipe_db(self):
        """"""
        logger.warning("Wiping the whole database")
        self.client.drop_database(self.db_name)
        logger.debug("Database wiped")
140346
public function dump()
    {
        $return = '';
        
        if (count($this->tables) == 0)
        {
            $this->addAllTables();
        }
        
        $return .= "--\n";
        $return .= "-- Backup ".$this->db['name']." - ".date('Y-m-d H:i:s')."\n";
        $return .= "--\n\n\n";
        
        $return .= "SET FOREIGN_KEY_CHECKS=0;";
        $return .= "\n\n\n";

        if ($this->addCreateDatabaseIfNotExists === true)
        {
            $return .= "CREATE DATABASE IF NOT EXISTS `".$this->db['name']."`;\n";
            $return .= "USE `".$this->db['name']."`;";
            $return .= "\n\n\n";
        }
        
        foreach ($this->tables as $table)
        {
            // We skip excluded tables
            if (in_array($table, $this->excludedTables))
                continue;

            $stmt = $this->dbh->query('SELECT * FROM `'.$table.'`');
            $stmt->execute();
            $num_fields = $stmt->columnCount();
            
            $return .= "--\n";
            $return .= "-- Table ".$table."\n";
            $return .= "--\n\n";
            
            // Dump structure ?
            if ($this->dumpStructure === true)
            {
                // Add DROP TABLE ?
                if ($this->addDropTable === true)
                {
                    $return .= 'DROP TABLE IF EXISTS `'.$table.'`;';
                    $return .= "\n\n";
                }

                $create_table_q = $this->query('SHOW CREATE TABLE `'.$table.'`', false);
                $create_table = $create_table_q[1];
                
                // Add IF NOT EXISTS ?
                if ($this->addIfNotExists === true)
                {
                    $create_table = preg_replace('/^CREATE TABLE/', 'CREATE TABLE IF NOT EXISTS', $create_table);
                }
                
                $return .= $create_table.";\n\n";
            }
            
            // Dump datas ?
            if ($this->dumpDatas === true)
            {
                $datas = $this->query('SELECT * FROM `'.$table.'`');

                foreach ($datas as $row)
                {
                    $return .= 'INSERT INTO `'.$table.'` VALUES(';
                    
                    for ($i = 0; $i < $num_fields; $i++) 
                    {
                        if (isset($row[$i]))
                        {
                            $row[$i] = addslashes($row[$i]);
                            
                            $return .= '"'.$row[$i].'"';
                        }
                        else
                        {
                            $return .= '""';
                        }
                        
                        if ($i < ($num_fields-1))
                        {
                            $return .= ', ';
                        }
                    }
                    
                    $return .= ");\n";
                }
            }
            
            $return .= "\n\n";
            $return .= "-- --------------------------------------------------------";
            $return .= "\n\n\n";
        }
        
        
        // Save content in file
        file_put_contents($this->filename.'.'.$this->extension, $return);
        
        
        // Zip the file ?
        if (!is_null($this->compressFormat))
        {
            $this->compress();
        }
        
        // Download the file ?
        if ($this->downloadFile === true)
        {
            $this->download();
        }
        
        // Delete the file ?
        if ($this->deleteFile === true)
        {
            $this->delete();
        }
    }
812664
def dump(self, raw=False):
        '''  '''
        raw_out = self.ser.read(self.ser.in_waiting)
        if raw:
            return raw_out
        return raw_out.decode(OUTPUT_ENCODING)