Possible to open a Berkeley 4.2 db file with DB_File?

1

187

Is it possible to open a Berkeley 4.2 db file with DB_File?

It doesn't not seem to want to open:

unless ($st = tie %db, "DB_File", 'somedbfile.db', O_RDONLY, 0640,
$DB_HASH) {
die "Cannot open file 'somedbfile.db': $!\n";
}

This code dies when I run it.
(And curiously $! seems to be empty:
Cannot open file 'somedbfile.db':
)

I did a db dump from the db file and heres the header:

VERSION=3
format=print
database=a_test_db
type=hash
h_nelem=3
db_pagesize=4096

Is there any way to read this version of a berk db file in Perl? Thanks.
(Google didn't give mcuh help either, I kept running into posts abotu
using berk 1.* .)
 
U

Uri Guttman

1> Is it possible to open a Berkeley 4.2 db file with DB_File?
1> It doesn't not seem to want to open:

IIRC, bsd dbm is not the exact same thing as berkeley db
(sleepycat). DB_File is for sleepycat's db and i think there is a
different tie/dbm module for berkeley db. so i think you are crossing db
types and modules which is why is failing.

uri
 
P

Paul Marquess

187 said:
Is it possible to open a Berkeley 4.2 db file with DB_File?

It doesn't not seem to want to open:

unless ($st = tie %db, "DB_File", 'somedbfile.db', O_RDONLY, 0640,
$DB_HASH) {
die "Cannot open file 'somedbfile.db': $!\n";
}

This code dies when I run it.
(And curiously $! seems to be empty:
Cannot open file 'somedbfile.db':
)

I did a db dump from the db file and heres the header:

VERSION=3
format=print
database=a_test_db
type=hash
h_nelem=3
db_pagesize=4096

Is there any way to read this version of a berk db file in Perl? Thanks.
(Google didn't give mcuh help either, I kept running into posts abotu
using berk 1.* .)

DB_File can read any Berkeley DB database file, as long as it has been built
with a compatible version of the Berkeley DB library. The Berkeley DB
database format has changed a number of times, so you need to make sure
DB_File has been built with the correct one.

Run this to see what version of Berkeley DB your DB_File was built with.

perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'

If you want to interoperate with a database file created with Berkeley DB
4.2, you need to have built DB_File with Berkeley DB 4.1 or 4.2.

cheers
Paul
 
1

187

Paul Marquess said:
DB_File can read any Berkeley DB database file, as long as it has been built
with a compatible version of the Berkeley DB library. The Berkeley DB
database format has changed a number of times, so you need to make sure
DB_File has been built with the correct one.

Run this to see what version of Berkeley DB your DB_File was built with.

perl -e 'use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}'

If you want to interoperate with a database file created with Berkeley DB
4.2, you need to have built DB_File with Berkeley DB 4.1 or 4.2.

Berkeley DB ver 3.003011

Though I found a module BerkeleyDB.pm at cpan, works great for various
versions, so much more flexible, and the beauty is that most of the
syntax is similar, though with some aditions. Works great from my
testing.
 
P

Paul Marquess

187 said:
Berkeley DB ver 3.003011

Then you need to build DB_File with a newer version of the Berkeley DB
library.
Though I found a module BerkeleyDB.pm at cpan, works great for various
versions, so much more flexible, and the beauty is that most of the
syntax is similar, though with some aditions. Works great from my
testing.

The story is exactly the same for my BerkeleyDB Perl module. If you need to
interoperate with a database created with a with a specific version of the
Berkeley DB library, you need to build my Perl module with a compatible
version of the Berkeley DB library.

Paul
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top