Print out the contents of $DBI::errstr
when an error occurs. This often shows more detail than the initial error message. For example, if the ODBC driver posts multiple errors, all of them display.
You can turn on Perl DBI tracing for all handles using the DBI class method with:
DBI->trace($trace_level) DBI->trace($trace_level, $trace_filename)
To enable trace information for a specific handle, use $h->trace
. The trace level is a number between 0 and 9, but usually 2 is sufficient.
Refer to the Perl documentation on DBI_TRACE
for more detailed information.
Recent versions of DBI include DBI::Shell, which allows you to use DBI to interact with your database from a shell session. This can be a useful way of verifying that your driver is installed and working. Start dbish
with either:
perl -MDBI::Shell -e shell
=Or-
dbish
Choose a database and then a data source when prompted. For example:
$ dbish DBI::Shell 10.6 using DBI 1.13 WARNING: The DBI::Shell interface and functionality are ======= very likely to change in subsequent versions! Available DBI drivers: 1: dbi:ADO 2: dbi:ExampleP 3: dbi:ODBC 4: dbi:Proxy Enter driver name or number, or full 'dbi:...:...' DSN: 3 Enter data source to connect to: 1: DBI:ODBC:Postgres 2: DBI:ODBC:test Enter data source or number, or full 'dbi:...:...' DSN: 2 Connecting to 'DBI:ODBC:test' as ''... @DBI:ODBC:test>
Use dbish
commands or SQL to query your database or change to another database. A good start is usually "/table_info," which lists all your tables. Use perldoc DBI::Shell
for a list of commands.