[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] Changing the current database in DBI
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@pm.org [mailto:omaha-pm-bounces@pm.org] On Behalf
Of Ryan Stille
Sent: Wednesday, August 24, 2005 9:48 AM
To: omaha-pm@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@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm