Home: Perl Programming Help: DBI:
How to to read MS-Access DB Table to a text file???



niyas.mohd
New User

Mar 15, 2009, 9:59 PM


Views: 10833
How to to read MS-Access DB Table to a text file???

Hi Team,

I have requirement to read a table and dump into a CSV file. The DB that i am using MS-Access DB.

Can you guys please give me some pointers?

Regards

Mohamed Niyas


FishMonger
Veteran / Moderator

Mar 16, 2009, 4:50 AM


Views: 10822
Re: [niyas.mohd] How to to read MS-Access DB Table to a text file???

You'll need the DBI (Database Interface) module and DBD::ODBC (ODBC database driver).

http://search.cpan.org/~timb/DBI-1.607/DBI.pm

http://search.cpan.org/~mjevans/DBD-ODBC-1.18/ODBC.pm


1arryb
User

Mar 16, 2009, 11:06 AM


Views: 10817
Re: [FishMonger] How to to read MS-Access DB Table to a text file???

Perl monks has a good thread that shows the DBI way and also points to some specialized MS Access conversion tools http://www.perlmonks.org/?node_id=474068

Cheers,

Larry


niyas.mohd
New User

Mar 19, 2009, 9:02 AM


Views: 10437
Re: [1arryb] How to to read MS-Access DB Table to a text file???

Hi guys,

Thanks a lot for your help. The access link was quiet useful. I am very new to perl. so just finding some difficulties while installing the modules. As of now my PPM says that DBI.PM installed. But while running the following code to know the drivers details, I am facing a error that perl can not locate the DBI.PM file.

Code:

use strict;

use DBI;
use DBI qw(:sql_types); # Can be used in where clause in case of search with types

# The below code shows the list of database drivers
# in perl along with the version

my @driver_names = DBI->available_drivers;
foreach my $drv (@driver_names)
{
print "$drv\n";
}

--------------------

Error:

Can't locate DBI.pm in @INC (@INC contains:

Can any one throw some light on this issue?

Note: I have included the lib path in the PATH variable too.

Regards

Mohamed Niyas M


1arryb
User

Mar 19, 2009, 9:12 AM


Views: 10433
Re: [niyas.mohd] How to to read MS-Access DB Table to a text file???

Hi niyas,

Is that the whole error message returned by Perl? It would be very suspicious if '(@INC contains:' ... NOTHING! It should at least return the installed perl library path. For example, on one of my machines:

Code
$ perl -e 'print "@INC\n";'

returns:

Code
/usr/lib64/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0  
/usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.10.0
/usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl
/usr/local/lib/perl5/site_perl/5.10.0
/usr/local/lib/perl/site_perl
/usr/lib/perl5/site_perl .


Cheers,

Larry