Similar to JDBC in java
use DBI;
my $dbh = DBI->connect('dbi:Pg:dbname=toy2;host=scabrous');
my $rows =
$dbh->selectall_arrayref('SELECT * FROM gene NATURAL JOIN gene_function');
foreach my $row (@$rows) {
foreach my $column (@$row) {
print "$column, ";
}
print "\n";
}
|
| Click here to see download |
The output looks like this:
gn00002 , foo, 35A7, transmembrane receptor,
gn00003 , bar, 60F1, glutamine-tRNA ligase,
gn00003 , bar, 60F1, ATP binding,
gn00004 , whee, 58C2, GPCR,
gn00004 , whee, 58C2, taste receptor,
|
DBI has a lot more to it - type "man DBI" for full instructions.
DBI is great as an API to the relational layer. However, as all queries return relations which are "flat" we lose the structure of the underlying data. Most java/perl/python/C programmers would prefer to work with either some kind of data structure or object model. We have to go beyond DBI to get this.
The GO database uses a similar system.
There are other object-relational mapping systems out there - both commercial and open source. These are all crap, because of the fundamental incompatibility of the two paradigms.