Accessing Pervasive.SQL With Perl

Page Last Modified: 07/04/10

Home Links ODBC (DBI) Contact

DBI + ODBC - Connecting To The Database

Using the standard 3 parameter method of calling the connect() method:

$dbHandle = DBI->connect('dbi:ODBC:$dsn', $name, $password);

which for the DEMODATA sample database installed by Pervasive.SQL results in:

$dbHandle = DBI->connect('dbi:ODBC:DEMODATA', '', '');

The Data Source Name (DSN) corresponds to the name of the ODBC datasource created either though the Pervasive Control Center or the ODBC driver manager. Pervasive.SQL 2000i and earlier rely on the operating system for security so you should not need to specify a name and password; version 8 and later may require credentials if the database administrator set them up.

A failure to connect results in $dbHandle being set to undef, so we must test this before using the handle for any further operations, including at the end of accessing the database when we shoudl disconnect from the database to free up resources:

$dbHandle->disconnect();

There are several alternative formats for the connection string, not all of them apparently being supported by the Pervasive.SQL ODBC driver. Examples of what are supported (or not) under Pervasive.SQL 9.5 can be found here.

Home Links ODBC (DBI) Contact

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