Perl accesses information held in relational databases through the DBI module, with additional modules (known as DBD modules) used to provide the specific code for individual database products such as MySQL. This module covers the sourcing and downloading of the DBI and DBD modules, and the use of DBI from within Perl. You don't use DBD directly, which ensures that your Perl code is very portable.
This topic is presented on public courses
MySQL,
Perl Programming,
Perl for Larger Projects
Examples from our training material
| aclog2table | Set up database for web access log records |
| aggy | Connecting Perl to a MySQL database |
| dbdhash.pm | Tie a Perl hash to a MySQL table through DBI |
| edbi | Example using many database access methods from DBI |
| fifthdbi | Perl DBI - display contents of MySQL table |
| firstdbi | Simple Perl DBI Query |
| hellosql | Accessing and SQL database with DBI and DBD modules |
| orange.pl | DBI used in a CGI script as a GUI to a table |
| sqlping | Using DBI and DBD to establish a connection and list available tables |
| tie_main | Exercise - main program to die hash to database |
| trains.sql | Data to create and populate train table for other examples |
| traintimes | Connect to an SQL database of train times |
Specialist books
Opentalk forum discussions related to this topic
DBI module missingConnecting to MySQL over an unreliable networkPerl DatabaseIs this a hash in an SQL insert statement
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
Flat databases.
Relational databases through SQL - Setup.
Checking that your relational database is available.
Installing the database independent module (DBI).
Install the Database Dependent drivers for MySQL.
Using DBI to access a MySQL database.
A further example.
Other databases.
Course links
The following web pages are used as references / examples in this module
[
Link] CPAN
(at http://cpan.hambule.co.uk/)
We check these links from time to time with a spider written in PHP. Latest full check was on Saturday, 12th June 2004. Titles are extracted from the web pages listed.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 600 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.