Is there a portable way to list the table names in *.mdb
files
(i.e. Microsoft Jet databases, also known as "Access databases") in Perl?
Usually I run my Perl scripts开发者_高级运维 on Windows with Cygwin.
I can run SQL queries on *.mdb
databases just fine with the DBD::ODBC
module, but it doesn't implement DBI's table_info
function, which would do exactly what I need. The DBD::ADO
and/or Win32::OLE
modules can probably be used instead, but they refuse to install under Cygwin, and I'd prefer to have a portable solution - ideally one that even works on Linux.
The DBIx::Class::Schema::Loader
module can be used to do this, and I understand it's being upgraded so it will actually work on *.mdb
files, but it has an enormous list of dependencies that I don't really want to install wherever I run my script just to get this single function.
Have you ever written Perl code that lists the table names in an *.mdb
file?
Which technique did you use and why?
Where has this rumor come from that DBD::ODBC does not support table_info - this is the third time in a week I've seen it:
perl -le 'use DBI; my $h = DBI->connect("dbi:ODBC:access_sample"); my $t = $h->table_info(undef, undef, undef, "TABLE");print DBI::dump_results($t);'
'/home/martin/test.mdb', undef, 'A', 'TABLE', undef
'/home/martin/test.mdb', undef, 'MSysNavPaneGroupCategories', 'TABLE', undef
'/home/martin/test.mdb', undef, 'MSysNavPaneGroupToObjects', 'TABLE', undef
'/home/martin/test.mdb', undef, 'MSysNavPaneGroups', 'TABLE', undef
'/home/martin/test.mdb', undef, 'MSysNavPaneObjectIDs', 'TABLE', undef
'/home/martin/test.mdb', undef, 'PERL_DBD_TABLE1', 'TABLE', undef
'/home/martin/test.mdb', undef, 'PERL_DBD_TEST', 'TABLE', undef
'/home/martin/test.mdb', undef, 'TestTable', 'TABLE', undef
'/home/martin/test.mdb', undef, 'X', 'TABLE', undef
'/home/martin/test.mdb', undef, 'unicode', 'TABLE', undef
10 rows
If you don't want the whole thing, then just grab the necessary parts from DBIx::Class::Schema::Loader::DBI::ADO::MS_Jet.
精彩评论