Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Dump In-memory DB_File to disk

by deibyz (Hermit)
on Oct 06, 2009 at 11:14 UTC ( [id://799439]=perlquestion: print w/replies, xml ) Need Help??

deibyz has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

Assume I have a DB_File tied hash created in memory, with something in the lines of:

my $db = tie my %h, "DB_File", undef, O_RDWR|O_CREAT
After populating it with some key/value pairs (potentially many), given some conditions I would like to create a proper db_file on disk with this data, but I would like to do it directly, without having to go through each %$h or something like that, to avoid performance penalties. I've been searching in the DB_File and dbopen documentations, but haven't found anyway to do it. Any ideas? Regards, D.

Replies are listed 'Best First'.
Re: Dump In-memory DB_File to disk
by BioLion (Curate) on Oct 06, 2009 at 11:33 UTC

    Using ad_export from DBD::AnyData you can convert in-memory databases into a file of specified format, including DBI databases. You can also pump out a host of other formats too.

    This may require some re-organising of your datastructure though? Possibly a silly thought, possibly not, but i am not sure how compliant Berkley DB and DBI are... Although by the looks of it, DBD::AnyData seems to support many database formats. HTH.

    Just a something something...
      That would be slower than direct approach
Re: Dump In-memory DB_File to disk
by Anonymous Monk on Oct 06, 2009 at 11:41 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://799439]
Approved by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-18 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found