作者:empty 页数:260 出版社:empty |
This is the definit iue book for database programming in Perl.AWu set or/As car twO Tim Hmc eThe primary interface for database programming in Perlis DBIProgramming the Perl DBI is coauthored by Alligator Descartes, one ofthe most active members of the DBI community, and by Tim Bunce, theThe book explains the architecture of DBI, sho us you howto write DBI-based programs and explains both DBI'nuances and the pe culi ritiesin u ent or of DBI.
DescriptionOne of the greatest strengths of the Perl programming language is its ability to manipulate largeamounts of data.Database programming is therefore a natural fit for Perl, not only for businessapplications but also for CGI-based web and intranet applications.The primary interface for database programming in Perlis DBI.DBI is a database-independentpackage that provides a consistent set of routines regardless of what database product you use-Oracle, Sybase, Ingres, Informix, you name it.The design of DBI is to separate the actual databasedrivers(DB Ds) from the programmer'sAPI, so any DBI program can work with any database, or evenwith multiple databases by different vendors simultaneously.Programming the Perl DBI is coauthored by All gator Descartes, one of the most active members ofthe DBI community, and by Tim Bunce, the inventor of DBI.For the uninitiated, the book explains thearchitecture of DBl and shows you howto write DBI-based programs.For the experienced DBIdabbler, this book reveals DBI's nuances and the peculiarities of each individual DBD.The book includes:This is the definitive book for database programming in Perl.The DBI is the standard database interface for the Perl programming language.The DBI is database-independent, which means that it can work with just about any database, such as Oracle, Sybase,While we assume that readers of this book have some experience with Perl, wed on't assume muchfamiliarity with databases themselves, The book starts out slowly, describing different types ofThis book is not solely about the DBI-it also concerns the more general subject of storing data in andretrieving data from databases of various forms.As such, this book is split into two related, butstandalone, parts.The first part covers techniques for storing and retrieving data without the DBI,and the second, much larger part, covers the use of the DBI and related technologies.Throughout the book, we assume that you have a basic grounding in programming with Perl and canput together simple scripts without instruction.If you don't have this level of Perl awareness, weOnce you're ready to read this book, there are some shortcuts that you can take depending on whatyou're most interested in reading about.If you are interested solely in the DBl, you can skip Chapter 2without too much of a problem, On the other hand, if you're a wizard with SQL, then you shouldprobably skip Chapter 3 to avoid the pain of us glossing over many fine details, Chapter 7isacomparison between the DBI and ODBC and is mainly of interest to database geeks, designaficionados, and those people who have win 32::0DBC applications and are desperately trying to portAn introduction to DBI and its designHowto construct queries and bind parametersWorking with database, driver, and statement handles
This introduction sets up the general feel for the book.This chapter covers the basics of storing and retrieving data cit her with core Perl functionsthrough the use of delimited or fixed-width flat-file databases, or ui an on-DBI modules suchas Any DBM_File, Storable, Data:; Dumper and friends.Although the DBI is n't used in thischapter, the way the Storable and Data::Dumper modules are used to pack Perl datastructures into strings can easily be applied to the DBl.This chapter is a basic overview of SQL and relational databases and how you can write simplebut powerful SQL statements to query and manipulate your database.If you already knowsome SQL, you can skip this chapter.If you don't know SQL, we advise you to read thischapter since the later chapters assume you have a basic knowledge of SQL and relationaldatabases.This chapter introduces the DBI to you by dise us sing the architecture of the DBI and basicDBI operations such as connecting to databases and handling errors.This chapter is essentialreading and dese ribes the framework that the DBI provides to let you write simple, powerful,and robust programs.This chapter is the meat of the DBI topic and discusses manipulating the data within yourdatabase-that is, retrieving data already stored in your database, inserting new data, anddeleting and updating existing data.We discuss the various ways in which you can performthese operations from the simple get it working”stage to more advanced and optimizedtechniques for manipulating data.
This chapter covers more advanced to pies within the sphere of the DBI such ass pee ifyingattributes to fine-tune the operation of DBI within your applications, working withLONG/LOB datatypes, statement and databasemetadata, and finaly transaction handling.This chapter discusses the differences in design between DBI and ODBC, the other portabledatabase API.And, of course, this chapter highlights why DBI is easier to program with.This chapter covers two topics that arent exactly part of the core DBI, perse, but areextremely useful to know about.First, we discuss the DBI shell, a command-line tool thatallows you to connect to databases and issue arbitrary queries.Second, we discuss the proxyarchitecture that the DBI can use, which, among other things, allows you to connect scripts onone machine to databases on another machine without needing to install any databasenetworking software.For example, you can connect a script running on a Unix box to aMicrosoft Access database running on a Microsoft Windows box.This appendix contains the DBI specification, which is distributed wth DBI.pnThis appendix contains useful extra information on each of the commonly used DBD sandtheir corresponding databases.
This appendix contains the charter for the Ancient Sacred Landsea pe Network, which focuseson preserving sites such as the megalithic sites used for examples in this book.ResourcesTo help you navigate some of the to pies in this book, here are some resources that you might want tocheckout before, during, and after reading this book:http://www.symbolstone.org/technology/perl/DBIhttp://www.per.com/CPANAn Introduction to Database Systems, by C.J.DateA Guide to the SQL Standard, by C.J.Date and Hugh Darwenhttp://w3.one.net/-jhoffman/sqltut.htmhttp://www.jcc.com/SQLPages/jccs_sql.htmhttp//www.contrb.andrew.cmi.edu/-shadow/sq.htm
Learning Perl, by Randal Schwartz and Tom ChristiansenProgramming Perl, by Larry Wall Tom Christi un sen, and Randal SchwartzThe Perl Cookbook, by Tom Christiansen and Nathan TorkingtonWriting Apache Modules with PerL and C, by Linco In Stein and Doug MacEachernBoutell FAQ(http://www.boutel.com/faq/) and othersMySQL&mSQL, by Randy Jay Yarger, George Reese, and Tim KingTypographical ConventionsThe following font conventions are used in this book:Constant widthItalic
The DBI homepage, This site contains lots of useful information about DBI and where to getthe various modules from.It also has links to the very active dbi-users mailinglist andarchives
This site in eludes the Comprehensive Perl Archive Network multiplexer, upon which you fnda whole host of useful modules including the DBI.This book is the standard textbook on database systems and is highly recommended reading.An excellent book that's detailed but small and very readable.These websites contain information, specifications, and links on the SQLquery language, ofwhich we present a primer in Chapter 3.Further information can be found by entering SQLtutorial or similar expressions into your favorite web searchengine.A hands-on tutorial designed to get you writing useful Perl scripts as quickly as possibleExercises(with complete solutions) accompany each chapter.A lengthy new chapterreferences, and Perl's object-oriented constructs.The authoritative guide to Perl version 5, the scripting utility that has established itself as theprogram mng tool of choice for the Word W de web, Unx system admin strain, and avastrange of other applications.Version 5ofPerlineludes object-oriented programming fat iesThe book is coauthored by Larry Wall, the creator of Perl.A comprehensive collection of problems, solutions, and practical examples for anyoneprogramming in Perl.To pies range from beginner questions to techniques that even the mostexperienced of Perl programmers will learn from.More than just a collection of tips andtricks, The Perl Cookbook is the long-awaited companion volume to Programming Perl, fl ledwith previously unpublished Perl arcana.This book teaches you howto extend the capabilties of your Apache webserver regardless ofwhether you usePerl orCas your programming language.The book explains the design ofA pach, mod_pe, and the Apa he AB.Foad bip e speci, it dio us ses theApache::DBI module, which provides advanced DBI functionality in relation to webservicessuch as persistent connection pooling optimized for serving databases over the Web.These links are invaluable to you if you want to deploy DBI-driven websites.They explain thedos and don'ts of CGI programming in general.For users of the MySQL and mSQL databases, this is avery useful book.It e overs not only thedatabases themselves but also the DBI drivers and other useful topics like CGI programmingis used for method names, function names, variables, and attributes.It is also used for codeexamples.
Preface
1.Introduction
From Mainframes to Workstations
DBI in the Real World
A Historical Interlude and Standing Stones
2.Basic Non-DBI Databases
Storage Managers and Layers
Query Languages and Data Functions
Standing Stones and the Sample Database
Flat-File Databases
Putting Complex Data into Flat Files
Concurrent Database Access and Locking
DBM Files and the Berkeley Database Manager
The MLDBM Module
Summary
3.SQL and Relational Databases
The Relational Database Methodology
Datatypes and NULL Values
Querying Data
Modifying Data Within Tables
Creating and Destroying Tables
4.Programming with the DBI
DBI Architecture
Handles
DataSource Names
Connection and Disconnection
Error Handling
Utility Methods and Functions
5.Interacting with the Database
Issuing Simple Queries
Executing Non-SELECT Statements
Binding Parameters to Statements
Binding Output Columns
do() Versus prepare()
Atomic and Batch Fetching
6.Advanced DBI
Handle Attributes and Metadata
Handling LONG/LOB Data
Tr