pwp71 has asked for the wisdom of the Perl Monks concerning the following question:
Hi everybody,
I have a sqlite database compressed with bzip2. I need to do some query into database without unzip into a file but using only a memory buffer. I tried with this code but didn't work and I didn't understand why.use DBD::mysql; use Time::Local; use strict ; use warnings ; use IO::Uncompress::Bunzip2 qw(bunzip2 $Bunzip2Error) ; use IO::File ; my $input = shift; my $buffer ; bunzip2 $input => \$buffer, BinModeOut => 1 or die "bunzip2 failed: $B +unzip2Error\n"; opendb(\$buffer); exit; sub opendb { my $file = shift; my $dbsql = DBI->connect("dbi:SQLite:${file}", "", "", {RaiseEr +ror => 1, AutoCommit => 1}); my $sq_1; my $sh_1; $sq_1 = "select * from tbl_xxx"; $sh_1 = $dbsql->prepare($sq_1); $sh_1->execute(); while( my $field = $sh_1->fetchrow_hashref()) { print "$field->{'pos'},"; } print "\n"; }
Someone could help me.
Thanks you in advance.
pwp71
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to do some query with sqlite.bz2 file
by Corion (Patriarch) on Jan 20, 2015 at 15:17 UTC | |
by jfroebe (Parson) on Jan 20, 2015 at 15:40 UTC | |
by pwp71 (Initiate) on Jan 20, 2015 at 16:04 UTC | |
|
Re: How to do some query with sqlite.bz2 file
by chacham (Prior) on Jan 20, 2015 at 19:00 UTC | |
|
Re: How to do some query with sqlite.bz2 file
by locked_user sundialsvc4 (Abbot) on Jan 20, 2015 at 16:58 UTC | |
by pwp71 (Initiate) on Jan 21, 2015 at 14:07 UTC |