
www.Usenet.com
| <-- __Chronological__ | <-- __Thread__ |
I have been trying to use the perl BerkeleyDB module to access a
Berkeley database. I have been having problems where everytime I run
my script it deletes the db file I have, unless I specify a "-Flags =>
DB_CREATE" option. When I do specify this option it "truncates" the
database and only shows the data I just put in. Any thoughts why this
happening?
PS: If there is a better place to post this question, let me know.
Here is the sample code I have been playing with:
#!/usr/bin/perl -w
use strict ;
use BerkeleyDB ;
use vars qw( %h $k $v ) ;
my $env = new BerkeleyDB::Env
-Home => "/home/cramert/",
-Verbose => 1,
-ErrFile => "error.out",
-Flags =>
DB_RECOVER|DB_CREATE|DB_INIT_CDB|DB_INIT_MPOOL;
my $filename = "whatever.db" ;
unlink $filename ;
tie %h, "BerkeleyDB::Btree",
-Filename => $filename,
-Env => $env,
-Flags => DB_CREATE,
-Property => DB_DUP
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
$h{'Wall'} = 'Larry' ;
$h{'Wall'} = 'Larry' ;
$h{'Smith'} = 'John' ;
#$h{'mouse'} = 'mickey' ;
#$h{'duck'} = 'donald' ;
foreach (keys %h)
{ print "$_\n" }
untie %h ;
| <-- __Chronological__ | <-- __Thread__ |