[ale] OT: Database conversion

Mike Fletcher fletch at phydeaux.org
Fri Nov 12 16:16:30 EST 1999


>>>>> "Daniel" == Daniel Boyd <dboyd at berry.edu> writes:

    Daniel> Hello, I'm hoping that someone on the ALE list has had to
    Daniel> do this before.  I am trying to find a
    Daniel> program/script/magic potion to convert older gdbm or ndbm
    Daniel> file to Berkeley DB 2.  I've got the db_load from Berkeley
    Daniel> DB 2, but I can't find anything to dump the existing
    Daniel> databases.  This is the output from 'file'
    Daniel> camps.topstory.dbm.dir: GNU dbm 1.x or ndbm database,
    Daniel> little endian

    Daniel> Can anyone help with this problem? Or am I better off
    Daniel> trying to reenter data into the application by hand?
    Daniel> Thanks in advance...

        If you've got a recent perl with the DB_File module compiled
and linked against DB2, maybe something along the lines of:


#!/usr/bin/perl

use GDBM_File;
use DB_File;

tie %in, 'GDBM_File', $infilename, &GDBM_WRCREAT, 0640;
tie %out, 'DB_File', $outfilename, O_RDWR|O_CREAT, 0640, $DB_HASH;

$out{$_} = $in{ $_ } for keys %in;

untie %in;
untie %out;

exit 0
__END__


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
678 443-6239(w)       |  scary questions." -- Jules                =(___)=
                      |                                               U






More information about the Ale mailing list