Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading existing Sqlite database into memory for fast computation

Does anyone knows how to load an existing database (Sqlite 3) into memory for fast computation in Perl, MATLAB or Java? Perl is preferred?

I am working on a project that needs intensive computation, and I want to keep the real database fixed. So I want to read the entire Sqlite3 database into memory and perform anything there in memory.

I know the basics of in-memory database connection, but seems like Perl can only create a new database using this way, rather than loading an existing one (which is the option I want to implement).

like image 859
z080328 Avatar asked Apr 28 '26 11:04

z080328


1 Answers

You can use the &sqlite_backup_from_file method in DBD::SQLite. If the handle against which you invoke it is opened on the ':memory:' database , the external database is read into it. A corresponding &sqlite_backup_to_file method allows you to write it back when you're done. These functions are effectively just wrappers around the C interface for backups

like image 138
Danny Woods Avatar answered Apr 30 '26 02:04

Danny Woods



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!