Skip to Main Content
Perl in a Nutshell, 2nd Edition
book

Perl in a Nutshell, 2nd Edition

by Nathan Patwardhan, Ellen Siever, Stephen Spainhour
June 2002
Beginner content levelBeginner
759 pages
80h 42m
English
O'Reilly Media, Inc.
Content preview from Perl in a Nutshell, 2nd Edition

Name

connect

Synopsis

$db_handle = DBI->connect(data_source, user, passwd,[\%attr])

Connects to the specified database, returning a database handle object. The connect method automatically installs the driver if it has not already been installed.

data_source

A string identifying the driver to connect to, and any other additional driver-specific information needed to identify the driver (e.g., a port number). The driver name is written in the form dbi:driver_name, e.g., dbi:mysql. (Default value is taken from the DBI_DSN environment variable.) For example, a connection string for the MySQL driver always starts with dbi:mysql:. The second colon should be followed by any information required by the driver to make the database connection. In the case of MySQL, you must supply a database name (bookdb in the following example), a hostname (localhost), and the port number of the database server (1114):

DBI:$driver:database=$database;host=$hostname;port=
$port
user

The username for the database connection. (Default value is taken from the DBI_USER environment variable.)

passwd

The password for the database connection. (Default value is taken from the DBI_PASS environment variable. Set this value at your own risk.)

\% attr

A hash reference defining attributes for the database handle.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl by Example, Fourth Edition

Perl by Example, Fourth Edition

Ellie Quigley
Perl Cookbook, 2nd Edition

Perl Cookbook, 2nd Edition

Tom Christiansen, Nathan Torkington
Perl in a Nutshell

Perl in a Nutshell

Nathan Patwardhan, Ellen Siever, Stephen Spainhour
Learning Perl, 7th Edition

Learning Perl, 7th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 0596002416Errata Page