per SQL prieinamos duomenų bazės

Informacijos šaltinis:
http://www.hermetica.com/technologia/DBI/
Principas

DBD metodai

Pavyzdžiai
#!/usr/local/bin/perl

use DBI;
use DBD::mysql;

$dbh = DBI->connect("DBI:mysql:test:senis", '', '');
$dbh->do('insert into test_1 (vardas, bilietas) values ("Petras", 9800)') 
	or print "Negaliu iterpti";
$sth = $dbh->prepare('select * from test_1 where bilietas>9700') or 
  die "Negaliu prepare'inti";

$sth->execute() or die "Negaliu execute'inti";

while (@row = $sth->fetchrow_array){
  print join(':', @row, "\n");
}
print "Viskas\n";
exit 0;



#!/usr/bin/perl -w
#
use CGI_LIB.pl;
use DBI;                        # Load the DBI Switch
$drh = DBI->install_driver( 'mSQL' );
                                # Load the mSQL driver. Returns a driver
                                # - handle in $drh
$dbh = $drh->connect( '', 'rubbish' );
                                # Connects via the mSQL driver ( as designated
                                # - by the driver handle $drh ) to a database
                                # - on the local machine called 'rubbish'.
die "Cannot connect: $DBI::errstr\n"
    unless $dbh;
                                # Check we've connected. Die if not.

&ReadParse();                   # A routine to parse a URL. See CGI.pm
&PrintHeader();

foreach $arg ( keys %CGI ) {     # The args are returned in a hash %in
    print "$arg: $CGI{$arg} \n";
  }
	
# Assume that we've submitted a form with the following fields:
#
#     o Name
#     o Email address
#
# Assume we have a table in the 'rubbish' database called 'cgistuff' with the
# - following fields:
#
#     o name CHAR(64)
#     o email CHAR(128)

$cursor = $dbh->do( "                   # Insert a row of data into the table
    INSERT INTO cgistuff VALUES         # - via the database handle returned
        ( $CGI{'name'}, $CGI{'email'} )" );       # - above       

# A $dbh->do doesn't require an execute or finish phase. It just happens
# - atomically.

$dbh->disconnect;               # Disconnect the database handle. This actually
                                # - disconnects you from the database specified
                                # - by $dbh

exit 0;