DBI(DBD::mysql)



2009 4月11日

接続時

my $dbh = DBI->connect(
‘DBI:mysql:database=sandbox;host=localhost;mysql_read_default_file=/etc/mysql/my.cnf’,
qw/id password/,
);

または接続後に

$dbh->{ mysql_enable_utf8 } = 1;


この辺の記事
http://www.geminium.com/chiba_blog/2009/02/







2009 2月6日

PERLでMySQLにデータを挿入する実験。

実験スクリプト

INSERT を100万回繰り返す。

for(1..1000000){
$sql = <<"EOM";
INSERT INTO `table_name`
(`col1`,`col2`,`col3`,`col4`) VALUES ('10','11','12','13');
EOM

$sth = $dbh->do($sql)|| die $dbh->errstr;
}

結果:途中でサーバエラー

Server error!

The server encountered an internal error and was unable to complete your request.

Error message:

Premature end of script headers: xxxx.cgi

If you think this is a server error, please contact the webmaster.

Error 500

httpd/error_logの出力:

[Fri Feb 06 20:04:00 2009] [error] [client xx.xxx.xxx.xxx] Premature end of script headers: sql.cgi

挿入されたデータ:約83万行

httpd.confの設定が、TimeOut 60によるエラーか?







2008 10月21日

$COUNT = $dbh->selectrow_array("SELECT COUNT(*) FROM  `テーブル名` WHERE `カラム` = '条件'");