DBD/XBase et Zip file

D

Dominique Crétel

Hello,

I have a DBase files into a zip file.

There is only one directory (firstdir) in the root of mydb.zip file,
which contain another directory (seconddir). This last directory
contains a set od DBase files like this :

mydb.zip
+---firstdir
+---seconddir
+---aaa.dbf
+---bbb.dbf
+---ccc.dbf
+---and so on...

I am looking for something like this (if it's possible ?) :

-----------------
#!/usr/bin/perl

use strict;
use warnings;

use DBI;
my $dbh = DBI->connect("DBI:XBase:./mydb.zip")
or die "error connecting to database :" . $DBI::errstr;

my $sth = $dbh->prepare("SELECT col1, col2 FROM table1")
or die "SQL error SQL:".$dbh->errstr();

$sth->execute or die "error while executing query:".$sth->errstr();
 
D

Dominique Crétel

Hello,

I'm trying again !
I have a gzip file containing DBase files like this :

mydb.gz:
firstdir
+---seconddir
+---aaa.dbf
+---bbb.dbf
+---ccc.dbf
+---...

This script below works fine if I uncompress it :

-----------------
#!/usr/bin/perl

use DBI;

my $dbh = DBI->connect("DBI:XBase:./firstdir/seconddir")
or die "error connecting to database :" . $DBI::errstr;

my $sth = $dbh->prepare("SELECT col1, col2 FROM table1")
or die "SQL error SQL:".$dbh->errstr();

$sth->execute or die "error while executing query:".$sth->errstr();
....
-----------------

Is it posible to work directly from the zip file ?
(but arranged for DBI)

-----------------
#!/bin/perl -w

my $file = "mydb.zip";
open (FIC, "|gzip -d < $file")
or die "Cannot read file '$file'";
....
 
X

xhoster

Dominique_Crétel said:
Hello,

I'm trying again !
I have a gzip file containing DBase files like this :

mydb.gz:
firstdir
+---seconddir
+---aaa.dbf
+---bbb.dbf
+---ccc.dbf
+---...

Are you sure that that is a gzip file? I don't believe gzip supports
archival of many files into one compressed file.
This script below works fine if I uncompress it :

-----------------
#!/usr/bin/perl

use DBI;

my $dbh = DBI->connect("DBI:XBase:./firstdir/seconddir")
or die "error connecting to database :" . $DBI::errstr;

my $sth = $dbh->prepare("SELECT col1, col2 FROM table1")
or die "SQL error SQL:".$dbh->errstr();

$sth->execute or die "error while executing query:".$sth->errstr();
...

Almost surely not. I'm guessing the file handle has to be seekable for
DBD::XBase, which compressed files generally aren't.
-----------------
#!/bin/perl -w

my $file = "mydb.zip";
open (FIC, "|gzip -d < $file")
or die "Cannot read file '$file'";

You pipe is on the wrong side.

open (FIC, "gzip -d $file |")

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,202
Latest member
MikoOslo

Latest Threads

Top