Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4615

How to load an SQLite Binary data dump into an in-memory read-only database instance?

$
0
0

I have an SQLite binary dump of around 10mb. The dumped database contains some catalogue data, which I need to be able to read from really fast from a Ruby application (sub-millisecond). Therefore I was thinking to load the datadump into an in-memory read only instance of SQLite - but - I have a hard time figuring out exactly how?

I have tried something like this, but it does not keep the db in-memory:

require 'sqlite3'require 'fileutils'# Path to the binary database dumpbinary_dump_path = 'path_to_your_binary_dump.db'# Create a temporary filetemp_db_path = 'temp_database.db'FileUtils.copy(binary_dump_path, temp_db_path)# Open the temporary databasedb = SQLite3::Database.new(temp_db_path)# Optionally, set the database to read-only modedb.execute('PRAGMA query_only = ON')

Viewing all articles
Browse latest Browse all 4615

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>