Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__     <-- __Thread__    

Having problem with perl BerkeleyDB module deleting db file



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__    


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.