Gautam's Blog

The technical blog of Gautam!

Browsing Posts in SQL

I am yet to check out Hivo, but here are the results otherwise. I am loading to an empty table, without much indexes; otherwise, I might need to disable indexing and re-enable indexing after the load data.

Real(Sec) User(Sec) System(Sec)
Writing to HDFS (MR time) 204.034 1.388 0.24
SQL Inserts from 4 Reducers (includes MR time) 2280.26 4.68 0.828
SQL Inserts from 10 Reducers (includes MR time) 2640.184 4.12 0.624
SQL Inserts from Namenode (does not include MR time) 7835.52 61.652 29.926
Inload file sequential Inserts (includes MR time) 290.46 13.509 2.604

SQLite

Comments off

SQLite Tutorial
SQLite Tutorial2

// Export to CSV
if($_GET['action'] == ‘export’) {

$rsSearchResults = mysql_query($sql, $db) or die(mysql_error());

$out = ”;
$fields = mysql_list_fields(‘database’,'table’,$db);
$columns = mysql_num_fields($fields);

// Put the name of all fields
for ($i = 0; $i < $columns; $i++) {
$l=mysql_field_name($fields, $i);
$out .= ‘”‘.$l.’”,’;
}
$out .=”\n”;

// Add all values in the table
while ($l = mysql_fetch_array($rsSearchResults)) {
for ($i = 0; $i < $columns; $i++) {
$out .=’”‘.$l["$i"].’”,’;
}
$out .=”\n”;
}
// Output to browser with appropriate mime type, you choose ;)
header(“Content-type: text/x-csv”);
//header(“Content-type: text/csv”);
//header(“Content-type: application/csv”);
header(“Content-Disposition: attachment; filename=search_results.csv”);
echo $out;
exit;
}

In some situations it might also be useful to force the user’s browser to download the file. Adding these lines should do the trick.

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Disposition: attachment; filename = $filename");
header("Content-Length: " . strlen($out));

Source: http://snipplr.com/view/2234/export-mysql-query-results-to-csv/

GRANT ALL PRIVILEGES ON aliceMysqlDatabase.* TO alice@localhost IDENTIFIED BY ‘alicePassword’;

PHP Tutorials interaction with database

MySQL Command

Import csv file into mysql database.

Good read.

Find number of duplicate field (address) in the table.

SELECT address,
COUNT(address)
FROM domain_ip
GROUP BY address
HAVING ( COUNT(address) > 1 )
Powered by WordPress Web Design by SRS Solutions © 2012 Gautam's Blog Design by SRS Solutions