Perl @ Web Programming
 Programming Shed : Programmer Store & Resources
|  ASP.NET  |  HTML / DHTML  |  Java / JavaScript  |  Perl  |  PHP  |  Python  |  XML  |
Perl Index - Perl Book :

Perl Book :
Programming the Perl DBI

Programming the Perl DBI
Check price @
Amazon.com
Amazon.ca
Amazon.co.uk


Programming the Perl DBI
by Alligator Descartes, Tim Bunce

Paperback: 346 pages
Dimensions (in inches): 0.74 x 9.22 x 7.04
Publisher: O'Reilly & Associates
ISBN: 1565926994; (February 2000)


The birth of new modules for the Perl scripting language is a regular occurrence, and the publication of an O'Reilly book about one of these modules is a sign of coming of age. Perl's DBI module, which facilitates the database-independent operation of Perl, achieves its rite of passage this month with the arrival of Alligator Descartes and Tim Bunce's excellent Programming Perl's DBI. Perl's DBI interface is maintained by Bunce and includes submodule interfaces to Oracle, MySQL, Sybase, Microsoft ODBC, and many other smaller databases. O'Reilly Perl book aficionados take note: this is the cheetah book, named for the animal that graces its cover.

Far from being a formalized how-to or man page, Programming Perl's DBI is a mini textbook in database programming, ideal for CPAN-savvy Perl programmers with little or no experience in database programming. Descartes and Bunce develop primitive notions of databases by using flat files, and they introduce relational databases with careful didactic motivation. The example database used throughout the book contains ancient sacred monolithic sites in the UK and elsewhere, of which Stonehenge is the most famous. Readers will learn about these primitive places while storing, updating, deleting, sorting, and locking their descriptors using flat files, nonrelational and relational databases, and a tutorial on SQL. The last chapters describe the peculiarities of interacting with ODBC and introduce DBI's Perl-less diagnostic shell and database proxying.

The authors use many modules--including DBI itself--that are not part of the vanilla Perl distribution, and Descartes and Bunce introduce them without explaining where to find or build them. Perl newbies with no CPAN experience may find themselves derailed early. The Storage module seems not to be available on CPAN at all (at the time of this writing). Fortunately, DBI and friends build, test, and install seamlessly under Linux/Red Hat 6.1.

At 350 pages, Programming the Perl DBI is 60 percent text--filled with highly annotated Perl code--and 40 percent appendices covering a detailed specification of DBI and 3-to-5-page descriptions of each of the 14 supported databases. Brevity is a large component of this book's wit. Clarity is the rest of it.

From Book News, Inc.: "The DBI is a database interface module for Perl. It defines a set of methods, variables and conventions that provide a consistent database interface independent of the actual database being used", explains Bunce, the architect and inventor of DBI. He and Descartes, one of the most active members of the DBI community, explain the architecture of DBI and show how to write DBI-based programs. For the DBI expert, they cover the nuances and peculiarities of each individual database driver. The basics of databases are well-covered, but some experience programming with Perl is assumed.Book News, Inc.®, Portland, OR

Book Description: One of the greatest strengths of the Perl programming language is its ability to manipulate large amounts of data. Database programming is therefore a natural fit for Perl, not only for business applications but also for CGI-based Web and Intranet applications.

The primary interface for database programming in Perl is DBI. DBI is a database-independent package that provides a consistent set of routines regardless of what database product is actually in use -- Oracle, Sybase, Ingres, Informix, you name it. The design of DBI is to separate the actual database drivers (DBDs) from the programmer's API, so any DBI program can work with any database, or even with multiple databases by different vendors simultaneously.

Programming the Perl DBI is coauthored by Alligator Descartes, one of the most active members of the DBI community, and by Tim Bunce, the inventor of DBI. For the uninitiated, the book explains the architecture of DBI and shows you how to write DBI-based programs. For the experienced DBI dabbler, this book explains DBI's nuances and the peculiarities of each individual DBD.

The book includes:
• An introduction to DBI and its design
• How to construct queries and bind parameters
• Working with database, driver, and statement handles
• Debugging techniques
• Coverage of each existing DBD
• A complete reference to DBI

This is the definitive book for database programming in Perl.

Book Info: Explains the architecture of DBI and explains how to write DBI-based programs. Explains DBI's nuances and the peculiarities of each individual DBD. Covers understanding DBI and its design, constructing queries and binding parameters, working with database, driver, statement handles, and debugging techniques.


Customer Reviews
Reviewer: Cat LeDevic from TN, USA
The only moan I have is that it didn't come out earlier.

The shop where I work asked me to cost a project using Perl as the back end for a T1 sales feed into an Oracle DB. They wanted to know if they could buy a package to do this. After a little research, I fell over the DBI. They were amazed at the "cost", and delighted with the speed.

I finally got the book about a week ago. Lo and behold, it also covered flat files. A large part of this shop's income comes from a custom doc library, flat files exported from many different DBs. So not only did the book aid with optimising the script I'd already written for the Oracle interface, but it's going to make all our lives easier for the next release of their commercial app.

The book is extremely well-written. (In a past life, I was a tech writer. Nothing worse than a badly written techie book.) The flow is well thought out. Not being a DB meister, the first few chapters were extremely helpful. In my case (and I'm sure, many others as well), I had to get up on DBs in a large hurry. With the Cheetah book, I was able to do so. The examples given are concise, easy to follow, and they _work_. The latter point is invaluable. I would recommend this book to anyone who uses Perl and the DBI.

Reviewer: Karen Remick from Fairbanks, AK United States
This book is very high on theory and light on tutorials. I bought the book because I need to interface perl programs with my MySQL database (One that the book doesn't cover explicitly). On P79 they finally get around to telling you how to call the DBI. Then they talk extensively about handles and error handling (Before you can even write anything which could have errors!). It is P86 before they tell you how to establish a connection to the database (Not ask it anything, that doesn't come for another 20 pages, just connect). You need to know the data source to do so, they recomend the DBI->data_sources() method; unfortunatly they do not tell you what that method is, or how to implement it. (You ready to scream yet?) They include a small program to look up the information, but when I typed it in, it only gave me cryptic errors (Undefined variable in concatination - there was no concatination, or any "." in the whole program, and the line number was that of a simple 'print "\n";' statement). I am only 1/2 way through the book so far, I am hoping it gets a bit more practical in the following chapters, but am not optimistic.

The authors seem to be very knowledgeable in their subject. They should have talked to someone who doesn't know anything about DBI (Preferably someone who is short on time and long on stuff that needs to be run) when they determined the content and layout of this book.

Reviewer: Philip R. Heath from Plano, TX United States
This is a good DBI reference for experienced perl programmers. The authors give you a good road map in the introduction so that you can find what you need to accomplish your task. I needed to interface to an existing database so I skipped chapter 2 on alternative persistent storage mechanisms. Having prior experience with SQL, I also skipped chapter 3.

Chapters 4-6 are where the majority of people are going to find useful information. There you will find good explanations on connecting to databases, executing SQL statements, and some advanced features such as binding variables. The authors give a good treatment of the various ways to execute queries with performance tradeoffs. Chapter 7 is only useful if you are working on a Windows platform. My database is on Solaris so this wasn't something that I needed.

As I said, though, what's there is good, but I there is definitely something missing. I needed to be able to call Oracle stored procedures as well as executing simple SQL queries. It would be nice to include some examples of calling stored procedures using the major vendors: Oracle, Informix, Sybase, etc. This information is hard to come by on the web. There are subtleties in using inout parameters in stored procedure calls that require some extra work in perl. You have to size variables large enough to store the largest value that is in the database. Since perl handles all string sizes dynamically, I used sprintf to force the strings to be large enough before calling the stored procedure. I don't know if you would run into these issues with outher databases, but it would be good to have this information with the rest of this text. That would make this fine book complete.

Reviewer: A reader from Kansas City, MO United States
Contrary to what some people have written about this book it does contain plenty of example code and it does contain working code. They do an excellent job of telling you what results from method calls and give example code using those methods. Having some knowledge about Perl does help when reading the book. They tell you what the DBI is, how it works, why it is useful, and then go on to show you how to make it a very useful tool. They clearly explain how to deal with retrieved data and give many examples of retrieving data and working with the retrieved data. They explain how to use the power of the DBI to make db connections easier and faster as your programs grow.

Once you understand what statement handles are and how they are used, what database handles are and how they are used(which are both clearly explained in the book), you can use the Appendix A as a quick reference for the method calls you might forget. Appendix B is a bit dated but gives detail about many database drivers you can use with the DBI. If you want something that has a better flow than the man pages this book is what you want.






Book Subjects
Learning Perl
Perl Reference Manual
Web Programming in Perl
 
Perl Essential
Learning Perl (3rd Edition)
by Randal L. Schwartz, Tom Phoenix
Programming Perl (3rd Edition)
by Larry Wall, Tom Christiansen, Jon Orwant
Perl Black Book, 2nd Edition
by Steven Holzner
CGI Programming with Perl
by Scott Guelich, Shishir Gundavaram, Gunther Birznieks, Linda Mui
Perl & XML (O'Reilly Perl)
by Erik T. Ray, Jason McIntosh
© 2005-2006, Programming Shed