PostgreSQLに接続する方法
Modified: 19 June 2005
"Pg"モジュールを使う
"Pg::connectdb"で、データベースに接続し、"$conn-> exec()"で、SQLコマンドを発行し処理します。
#!/usr/bin/perl print "Content-type: text/html\n\n"; use Pg; $conn = Pg::connectdb("host=192.168.0.6 dbname=dbname user=postgres"); $res = $conn-> exec("select * from tablename"); while(@item = $res-> fetchrow) { print "@item[0] @item[1] @item[2] @item[3]"; print ("<br>\n"); }