On Sun, 19 Jan 2003 18:12:26 -0600, Paul DuBois wrote:
>At 19:05 -0500 1/19/03, Mark Riehl wrote:

Hi Mark

>>I thought I could connect to the test database, create the new

To be pedantic, the test db may not exist. I'd connect either to the
mysql db or the null db :-). See demo below. I don't know if any db
server other than mysql accepts a null db.

Tested code:
-----><8-----
#!/usr/bin/perl
#
# Name:
#       connect2nulldb.pl.
#
# Purpose:
#       Try connecting to a null db name.
#
# Note:
#       tab = 4 spaces || die.
#
# Author:
#       Ron Savage <[EMAIL PROTECTED]>
#       http://savage.net.au/index.html

use strict;
use warnings;

use DBI;
use Error qw/:try/;

# -----------------------------------------------

try
{
        my($dbh) = DBI -> connect
        (
                "DBI:mysql::127.0.0.1", 'route', 'bier',
                {
                        HandleError                     => sub {Error::Simple -> 
record($_[0]); 0},
                        PrintError                      => 0,
                        RaiseError                      => 1,
                }
        );
        $dbh -> do('use mysql'); # Cannot omit this line. Try it!
        my(@table) = $dbh -> tables();
        print map{"$_. \n"} @table;
}
catch Error::Simple with
{
        my($error) = 'Error::Simple: ' . $_[0] -> text();
        chomp($error);
        print $error;
};
-----><8-----

Output:
-----><8-----
columns_priv.
db.
func.
host.
tables_priv.
user.
-----><8-----

--
Cheers
Ron Savage, [EMAIL PROTECTED] on 20/01/2003
http://savage.net.au/index.html


Reply via email to