From: Celeste S. B. <csb...@ci...> - 2003-08-05 20:04:12
|
It sure would be nice if someone wrote a module and posted it to CPAN (hint, hint) Celeste Suliin Burris Systems Administrator Tacoma Economic Development Dept. csb...@ci... > Date: Mon, 4 Aug 2003 09:17:55 -0400 > From: "Kyle R. Burton" <mo...@vo...> > To: mdb...@li... > Subject: Re: [mdb-dev] MDB-Tools and Perl > Reply-To: "Kyle R. Burton" <mo...@vo...> > >> I am curious as to the ways in which one can interact with mdb-tools from >> within a perl script? I am not a strong programmer. I can use the system >> command from perl to start the command line utilities but can not pass it the >> required information. Does anyone have much experience of working with both >> MDB tools and perl? > > We have used MDB tools from Perl to list the tables in an MDB (using > mdb-tables), and get all the records from a table (using mdb-export). > > We either used backticks or open to read from those commands. A direct call > to the C functions (libmdb) would probably be a better long teram solution > (DBD::mdbtools would be even better). > > Pseudo code for we're using looks like: > > # returns an array of table names > sub list_tables > { > my($fileName) = @_; > my $cmd = "mdb-tables $fileName"; > my $output = `$cmd`; > if( 0 != ($? >> 8) ) { > die "Error obtaining tables list [$cmd]: $output : \$!=>$! : \$?=>$?"; > } > my @lines = split(/[\s\r\n]+/,$output); > return @lines; > } > > # returns an array of arrayrefs (array of records) > sub get_records > { > my($fileName,$tableName) = @_; > my $cmd = "mdb-export -d'\t' -Q $fileName '$tableName' |; > my $fh; > unless( open( $fh, $cmd ) ) { > die "Error opening mdb read handle: $! : cmd: '$cmd'"; > } > my @lines = <$fh>; > close $fh; > my @records; > foreach my $line ( @lines ) { > my @fields = split('\t',$line); > $fields[-1] =~ s/[\r\n]+//; > push @records, \@fields; > } > return @records; > } > > > > -- > > ------------------------------------------------------------------------------ > Wisdom and Compassion are inseparable. > -- Christmas Humphreys > mo...@vo... http://www.voicenet.com/~mortis > ------------------------------------------------------------------------------ |
From: Kyle R. B. <mo...@vo...> - 2003-08-07 02:37:37
|
> It sure would be nice if someone wrote a module and posted it to CPAN (hint, > hint) Ok. It'm not posting this to CPAN, but I just wrote up a quick hack that rides on top of mdbtools: http://www.neverlight.com/~mortis/mdbtools/Mdbtools-0.01.readme http://www.neverlight.com/~mortis/mdbtools/Mdbtools-0.01.tar.gz I also put up a copy of the 0.5rc2 sources with my patches applied in case anyone wants at them: http://www.neverlight.com/~mortis/mdbtools/mdbtools-0.5rc2-krb.tar.gz Hopefully this will be useful to someone... Kyle R. Burton -- ------------------------------------------------------------------------------ Wisdom and Compassion are inseparable. -- Christmas Humphreys mo...@vo... http://www.voicenet.com/~mortis ------------------------------------------------------------------------------ |
From: Brian B. <ca...@ai...> - 2003-08-07 18:22:55
|
Hi all, First apologies for not keeping up with mdbtools lately, two jobs and two children is taking a toll. If people have outstanding patches, *please* post them to sourceforge, so a) I don't lose them and b) others can apply them in the meantime. On the perl front, the original idea was to use DBD::ODBC with the MDB Tools ODBC driver to accomplish this. I got something working when I tried it oh so long ago. After I move next friday and again have DSL, I'm hoping to have enough time to apply patches and put out a release sometime in September. Cheers, Brian On Wed, 6 Aug 2003, Kyle R. Burton wrote: > > It sure would be nice if someone wrote a module and posted it to CPAN (hint, > > hint) > > Ok. > > It'm not posting this to CPAN, but I just wrote up a quick hack that > rides on top of mdbtools: > > http://www.neverlight.com/~mortis/mdbtools/Mdbtools-0.01.readme > http://www.neverlight.com/~mortis/mdbtools/Mdbtools-0.01.tar.gz > > I also put up a copy of the 0.5rc2 sources with my patches applied > in case anyone wants at them: > > http://www.neverlight.com/~mortis/mdbtools/mdbtools-0.5rc2-krb.tar.gz > > Hopefully this will be useful to someone... > > Kyle R. Burton > > > |