[Omaha.pm] Changing the current database in DBI

Kenneth Thompson kthompson at omnihotels.com
Wed Aug 24 08:15:17 PDT 2005


Shot in the dark here- but is it a DBI issue, or an SQL issue? Most ANSI
compliant sql db's use [] to enclose object names which don't comply...
so I'd try :

$dbh->do("USE [$database]");

Hth
Kenn


-----Original Message-----
From: omaha-pm-bounces at pm.org [mailto:omaha-pm-bounces at pm.org] On Behalf
Of Ryan Stille
Sent: Wednesday, August 24, 2005 9:48 AM
To: omaha-pm at pm.org
Subject: [Omaha.pm] Changing the current database in DBI

I have a perl script that goes through a list of mysql databases and
does things.  It gets the list of databases from the SHOW DATABASES
command.

As I go through and issue SQL commands in each database, I use
$dbh->do("USE $database"); to change databases.

This worked fine until I added some databases with dashes in their
names.  Now when the script runs I get:

DBD::mysql::db do failed: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '-clientvars' at line 1 at /usr/sbin/mysql_backup.pl
line 27.

I tried adding single quotes around $database, but that didn't help.  If
I use the mysql command line interface, I can use the USE command with
or without quotes, on any database, and it works fine.

Is there perhaps a DBI method I should be using to switch databases?

Thanks,
-Ryan

_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



More information about the Omaha-pm mailing list