Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Cultured Perl: Embedding Perl in database tables

By Teodor Zlatanov
2005-04-27


Class::DBI Capabilities

The Class::DBI module is a powerful Perl module that can model relational database table designs in code. With it, one-to-one and one-to-N relationships are possible, and you can even create an N-to-N relationship with some extra work (all covered in the Class::DBI documentation; see the link to the Class::DBI homepage in Resources).

Using the Class::DBI module is simple once the setup code is written. The setup code is usually a few lines that describe the database such as the database driver, username and password, and where to find it. From that point on, inserting, deleting, and modifying records are one-line operations. The fact that Class::DBI simplifies record operations to one-liners makes embedding Perl code in the database feasible and palatable. Anything longer would be too unwieldy.

Class::DBI can do much, much more. Be sure to look at the documentation -- I guarantee you will get a headache (and some happy surprises) from slapping your forehead so many times, so grab some aspirin first.

Now let's set up some tables.

Tutorial Pages:
» Put Perl into your RDBMS Design to Reach Database Nirvana
» Class::DBI Capabilities
» Setting up Tables
» Embedded Deletion
» Embedded Modifications
» Compatibility with Other Languages and Alternative Approaches
» Conclusion
» Resources


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» Random subroutines in Perl
» Log Script Use
» Creating Perl Modules for Web Sites
» Bit Vector, Using Perl Vec
» Build a Perl/CGI Voting System
» Perl Range Operator

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources