Accessing Pervasive.SQL With Perl

Page Last Modified: 07/04/10

Home Links ODBC (DBI) Contact

use strict;
use warnings;
use DBI;

eval {
DBI->trace(0);

print "Connection 1 - dbi:DriverName:database_name\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 2 - no string supplied....should use DBI_DSN \n";
$ENV{'DBI_DSN'} = 'dbi:ODBC:DEMODATA';
$dbHandle = DBI->connect('', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 3 - only 'dbi::' supplied....should use DBI_DRIVER \n";
$ENV{'DBI_DRIVER'} = 'ODBC';
$dbHandle = DBI->connect('dbi::DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#commented out blocks are failing to connect...
#print "Connection 4 - dbi:DriverName:database_name\@hostname:port\n";
#$dbHandle = DBI->connect('dbi:ODBC:DEMODATA@127.0.0.1:1583', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
#print "Disconnecting...\n";
#$dbHandle->disconnect();

print "Connection 5 - dbi:DriverName:DSN=database_name\n";
$dbHandle = DBI->connect('dbi:ODBC:DSN=DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#print "Connection 6 - dbi:DriverName{Attributes}:database_name\n";
#$dbHandle = DBI->connect('dbi:ODBC{PrintError=>0,RaiseError=>1,AutoCommit=>0}:DEMODATA', '', '');
#print "Disconnecting...\n";
#$dbHandle->disconnect(); 1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

use strict;
use warnings;
use DBI;

eval {
DBI->trace(0);

print "Connection 1 - dbi:DriverName:database_name\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 2 - no string supplied....should use DBI_DSN \n";
$ENV{'DBI_DSN'} = 'dbi:ODBC:DEMODATA';
$dbHandle = DBI->connect('', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 3 - only 'dbi::' supplied....should use DBI_DRIVER \n";
$ENV{'DBI_DRIVER'} = 'ODBC';
$dbHandle = DBI->connect('dbi::DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#commented out blocks are failing to connect...
#print "Connection 4 - dbi:DriverName:database_name\@hostname:port\n";
#$dbHandle = DBI->connect('dbi:ODBC:DEMODATA@127.0.0.1:1583', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
#print "Disconnecting...\n";
#$dbHandle->disconnect();

print "Connection 5 - dbi:DriverName:DSN=database_name\n";
$dbHandle = DBI->connect('dbi:ODBC:DSN=DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#print "Connection 6 - dbi:DriverName{Attributes}:database_name\n";
#$dbHandle = DBI->connect('dbi:ODBC{PrintError=>0,RaiseError=>1,AutoCommit=>0}:DEMODATA', '', '');
#print "Disconnecting...\n";
#$dbHandle->disconnect(); 1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

Home Links ODBC (DBI) Contact

All content on this site is copyright
Neil Hughes 2010 - 2017

use strict;
use warnings;
use DBI;

eval {
DBI->trace(0);

print "Connection 1 - dbi:DriverName:database_name\n";
my $dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 2 - no string supplied....should use DBI_DSN \n";
$ENV{'DBI_DSN'} = 'dbi:ODBC:DEMODATA';
$dbHandle = DBI->connect('', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

print "Connection 3 - only 'dbi::' supplied....should use DBI_DRIVER \n";
$ENV{'DBI_DRIVER'} = 'ODBC';
$dbHandle = DBI->connect('dbi::DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#commented out blocks are failing to connect...
#print "Connection 4 - dbi:DriverName:database_name\@hostname:port\n";
#$dbHandle = DBI->connect('dbi:ODBC:DEMODATA@127.0.0.1:1583', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
#print "Disconnecting...\n";
#$dbHandle->disconnect();

print "Connection 5 - dbi:DriverName:DSN=database_name\n";
$dbHandle = DBI->connect('dbi:ODBC:DSN=DEMODATA', '', '', {PrintError=>0,RaiseError=>1,AutoCommit=>0});
print "Disconnecting...\n";
$dbHandle->disconnect();

#print "Connection 6 - dbi:DriverName{Attributes}:database_name\n";
#$dbHandle = DBI->connect('dbi:ODBC{PrintError=>0,RaiseError=>1,AutoCommit=>0}:DEMODATA', '', '');
#print "Disconnecting...\n";
#$dbHandle->disconnect(); 1;
}
or do {
print "Error: $DBI::err - $DBI::errstr\n";
};

print "Finished\n";

DBI + ODBC - Connection String Examples