* 接続/切断 [#g4349098]
** DSN [#l7129823]
# MySQL
$dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
# PostgreSQL
$dsn = "dbi:Pg:dbname=$dbname;host=$host;port=$port";
# SQLite
$dsn = "dbi:SQLite:dbfile.db";
** 接続/切断 [#pdcbd776]
$dbh = DBI->connect($dsn, $user, $pass, {RaiseError=>1, PrintError=>0, AutoCommit=>1}) or die $DBI::errstr;
$dbh->disconnect;
** 結果セットの文字列をUTF8フラグ付きにする [#sb7da176]
my $dbh = DBI->connect( $DSN, 'user', 'pass', { pg_enable_utf8 => 1 } ) or die $DBI::errstr;
- MySQLの場合: mysql_enable_utf8 => 1