Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Perl: How to Connect to mysql

#!/perl/bin
use DBI;
use strict;
my $db_connect = DBI->connect('dbi:mysql:MyDatabase',
								'username',
								'password',
								 { PrintError =

Perl: listing available database Drivers

#!/usr/bin/perl
use strict;
use DBI;
my @drivers = DBI->available_drivers();
print "Installed Drivers:";
foreach my $db_driver (@drivers)
{
  print "$

Perl: Retrieve the value of designated column in the current row of DBM

#!/bin/perl
use AnyDBM_File;
my $file_BD="c:/BD/Students.dbm";   
tie(%dbm, 'AnyDBM_File',$file_BD, O_CREAT|O_RDWR, 0644)
	or die "Cannot open databas

Perl: Find the number of rows affected by a SQL query

#!/usr/bin/perl
use warnings;
use strict;
use DBI;
# Create a connection to MySQL Database
my $db_connect = DBI->connect('dbi:mysql:Customers',

Perl: Use DBI to connect to a Microsoft Access database

#!c:/perl/bin
use DBI;
use strict;
# Create a connection to MS ACCESS(.mdb)
 my $db_connect = DBI->connect("dbi:ODBC:Test");
my $Query="SELECT FirstN

Perl: How to Connect to Oracle

#!/perl/bin
use DBI;
use strict;
# Create a connection to Oracle Database
my $db_connect = DBI->connect('dbi:Oracle:Test','scott','tiger');
my $Query=

Perl: Using Transactions

#!/usr/bin/perl
use warnings;
use strict;
use DBI;
# Create a connection to MySQL Database
my $db_connect = DBI->connect('dbi:mysql:Students',

Perl: How to Create Portable Database Programs with the AnyDBM Module

#!/usr/bin/perl
use strict;
use warnings;
use AnyDBM_File;
use POSIX;
my %dbm;
my $file_BD="c:/BD/Users.dbm";      #Database Name
tie (%dbm, 'AnyDBM_F

Perl: Read a CSV File using SQL Query

#!/usr/bin/perl
use DBI;
$csv_connect = DBI->connect("dbi:CSV:f_dir=c:/test.csv", "", "",
                    { AutoCommit => 1, RaiseError => 1 });

Perl: Finding database DSN (Data Source Name)

#!/usr/bin/perl
use strict;
use DBI;
my @drivers;
@drivers = DBI->available_drivers;
foreach my $driver (@drivers)
{
  print "Driver $driver";
  my @

Perl: Inserting and Retrieving Data from a DBM File

#!/bin/perl
use AnyDBM_File;
use strict;
# Connect to DBM Data file
dbmopen(my %dbm, "c:/BD/Users.dbm", 0666);
# retrieving data from dbm file
my $va

Perl: How to delete a DBM file.

#!/usr/bin/perl
use AnyDBM_File;
my $file_BD="c:/BD/Users.dbm";
unlink $FILENAME
    or die "Error: $!n";
tie(%HASH => "AnyDBM_File", $file_BD)
    o

Perl: Connecting to the MySQL Server

#!/usr/bin/perl
use DBI;
$dbh = DBI->connect('dbi:mysql:database', 'username', 'password',
            { RaiseError => 1, AutoCommit => 1});
$sth = $

Perl: Dealing with Database Errors

#!/usr/bin/perl
use DBI;
$dbh = DBI->connect('dbi:mysql:database', 'username', 'password',
                    { RaiseError => 1 , AutoCommit => 1});