Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Transfer a in-memory SQLite database to disk

by dsheroh (Parson)
on Jul 03, 2012 at 10:57 UTC ( #979641=note: print w/ replies, xml ) Need Help??


in reply to Transfer a in-memory SQLite database to disk

No need to mess with ATTACH. DBD::SQLite provides an sqlite_backup_to_file method.

(And, to respond to the earlier "shouldn't you just be creating the db on disk in the first place?" comment, I know of this method thanks to a game I was working on that ran from an in-memory database and periodically checkpointed itself to disk.)


Comment on Re: Transfer a in-memory SQLite database to disk
Download Code
Re^2: Transfer a in-memory SQLite database to disk
by Anonymous Monk on Jul 03, 2012 at 11:04 UTC

    Neato :)

    JIC , grep -ri attach DBD-SQLite-1.37 </t>

    t/16_column_info.t 31:# 3. Attach a memory database 32:ok( $dbh->do('ATTACH DATABASE ":memory:" AS db3'), 'ATTACH DATABASE + ":memory:" AS db3' ); 34:# 4. Create a table on the attached database t/35_table_info.t 55:# Attach a memory database 56:ok( $dbh->do('ATTACH DATABASE ":memory:" AS db3'), 'ATTACH DATABASE + ":memory:" AS db3' ); 58:# Create a table on the attached database 94:# Create another table "one" on the attached database
Re^2: Transfer a in-memory SQLite database to disk
by saumitra121 (Novice) on Jul 03, 2012 at 12:59 UTC
    thanks...that's exactly what I was looking for.

    For future visitors...below is the syntax to backup a in-memory database to disk.

    $dbh = DBI->connect('dbi:SQLite:dbname=:memory:'); .... .... do something .... $dbh->sqlite_backup_to_file($filename);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979641]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2014-12-27 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls