Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.mdb to .txt conversion ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
Hi,

Is any way to convert the above using any Perl module ?
Did not seem to find anything matching on CPAN...
Thanks

Long live king Moshiach !
 
Thanks,

ended up doing:

use DBI;

my $database = shift;
my $driver = "Microsoft Access Driver (*.mdb)";
print "$database :\n";
print "-----------\n\n";
my $dsn = "dbi:ODBC:driver=$driver;dbq=$database";
my $dbh = DBI->connect("$dsn") or die "Couldn't open database: $DBI::errstr; stopped";

my $sth = $dbh->table_info( "", "", "", "TABLE" );

while ( my ($catalog, $schema, $table, $type) = $sth->fetchrow_array() ) {
if ($table) {
print "\n$table :\n";
print "--------\n";
my $sql = "select * from $table";

# Prepare the SQL query for execution
my $sth = $dbh->prepare ("$sql")
or die "Couldn't prepare statement:$DBI::errstr; stopped";

# Execute the query
$sth->execute() or die "Couldn't execute statement: $DBI::errstr; stopped";

# Fetch each row and print it
while ( my (@row) = $sth->fetchrow_array() ) {
print "$_\t" foreach (@row);
print "\n";
}
}
}
$dbh->disconnect();

Long live king Moshiach !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top