A Portable Interface to Web Databases
Using the Perl DBD/DBI Database-Abstraction Libraries
By Mike Miller
Perl has always been well-suited for manipulating data. So, it's not surprising that people would write extensions to Perl to interface directly to their databases. In the days of Perl 4 there were many such interfaces, like oraperl, which interfaced to Oracle, sybperl (Sybase), and ingperl (Ingress). Each interface had its own unique syntax and was incompatible with the others. This meant that any time you wanted to switch to another database product, you had to port code.
The object-oriented features of Perl 5, however, made it possible to approach this problem in a more portable and robust manner. That's where the Perl DBD/DBI database-abstraction libraries come in. DBI refers to Data Base Interface, and DBD stands for Data Base Driver. DBD/DBI allows you to connect to databases in a portable way. With the DBI interface it is possible to port Perl applications from one database to another, and to open connections to one or more databases from different vendors. This makes it simple to move data back and forth between different vendors' products. In this article, we'll look at how to use the Perl DBD/DBI database-abstraction libraries to load a database and query it via the Web. I'll be using the handy Perl 5 CGI.pm library to make generating Web pages with Perl easier.
Building a Database
|