From Mageia wiki
Jump to: navigation, search

Packages

  • perl-DBD-Pg

From SRPM:

  • perl-DBD-Pg


Testing procedure

--- Create a test database ---

su -l postgres -c "psql" 
postgres=# drop database if exists qatest;
postgres=# create database qatest;
CREATE DATABASE
postgres=# \c qatest;
You are now connected to database "qatest".
qatest=# create table qatest_table (id INT, caption VARCHAR);
CREATE TABLE
qatest=# \d qatest_table
       Table "public.qatest_table"
 Column  |       Type        | Modifiers
---------+-------------------+-----------
 id      | integer           |
 caption | character varying |

qatest=# insert into qatest_table values (1, 'mageia'), (2, 'QA');
INSERT 0 2
qatest=# \q

--- Start perl in interactive debug mode to test DBI ---

perl -d -e 1

Then inside the debugger:

use DBI
$dbh = DBI->connect ( "dbi:Pg:dbname=qatest", "postgres", "")
print defined($dbh) #must print "1"
$sth = $dbh->prepare("SELECT * FROM qatest_table")
$sth->execute()
print $sth->fetchrow() #displays "1mageia"
print $sth->fetchrow() #displays "2QA"