Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Putting an SQLite DB file into memory

by clueless newbie (Deacon)
on Sep 25, 2016 at 23:12 UTC ( #1172586=note: print w/replies, xml ) Need Help??


in reply to Putting an SQLite DB file into memory

Hi, stevieb. I do this all the time, connect to a memory db as
$dbh=DBI->connect('dbi:SQLite:database=:memory:','','',{ PrintError=>0 +,RaiseError=>1 });
then use
$dbh->sqlite_backup_from_file( $filename ) or $dbh->sqlite_backup_to_file( $filename )
as desired.

Replies are listed 'Best First'.
Re^2: Putting an SQLite DB file into memory
by stevieb (Canon) on Oct 04, 2016 at 13:35 UTC

    This works brilliantly, and the feature is built right in! This is more than what I was looking for. Thanks clueless newbie :)

    I'm finally writing the tests for my app, and this works perfectly for testing, instead of copying a db file then removing it in each test file.

    I keep all configuration inside of the db as well as the data (generated every five seconds), so I think what I'm going to do is have the config aspect in a separate db on disk, and the streaming data in memory which I back up with a timed event.

    For those wondering, this is an application that gathers grow room environment information (temp, humidity so far, to also include water level, pH, EC/PPM etc for hydroponics, and soil moisture content data for soil) and writes it to what could be a volatile database. However, the configuration aspect of the system turns on/off electrical systems (lights, fans, humidifiers), so that part of the db must be reliably on disk, in case of a system crash/reboot, it needs to remember everything (timing, on/off configuration etc).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2019-12-10 22:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?