XP is just a number | |
PerlMonks |
Re: Best Perlish way to test if a mysql table exists?by digiryde (Pilgrim) |
on Jan 31, 2005 at 15:33 UTC ( [id://426628]=note: print w/replies, xml ) | Need Help?? |
I know this could be done, but I do not know if it is the best way. All of the mysql tables are stored in a directory as tablen_name.file_extension. I am not sure if the file extension is the same for every table type or not (mine are *.ISDm, *.ISM and *.frm). Something liek this (minimally tested)
You can find the path to the db directory in the configuration file, either "/etc/mysql/my.cnf" or "/etc/my.cnf". If might be somewhere else, but I have always found it in one of these places. The line you want is the "datadir=" line. If all of your tables are the same database type, then they should all have the same extensions (as far as I know).
It works for me on my system, but I do not have the number of tables that you have, and probably not the same setup. This is obviously black magic, as I know of no guarentee that the tables will always be exposed like this, but it it does work for me. Otherwise, your best bet (and the best solution) sounds like you need to trap the errors.
In Section
Seekers of Perl Wisdom
|
|