目次 |
---|
・PostgreSQLに接続 |
$dhb = DBI->connect("dbi:Pg:dbname=データベース名:host=ホスト名",ユーザ名,パスワード名);というように記述します。具体的にはDB名がtest、ユーザ名がpostgres、パスワードがpostgresとし、同一マシンでPostgreSQLが起動しているとすると
$dhb = DBI->connect("dbi:Pg:dbname=test:host=localhost",postgres,postgres);と記述します。以下、サンプルです。
#!usr/bin/perl use DBI; my $db; $db=DBI->connect("dbi:Pg:dbname=test:host=localhost",postgres,postgres); $arr=$db->selectall_arrayef("select * from employee");