sxingfeng
sxingfeng

Reputation: 1087

Is it possible to load SQLite db in to memory and execute query?

I am programing under C++, windows, I want to retrieve all content in SQLite DB, so I make use of "select * from XXX", The DB is about 4M, However if the system restarted, the first time query will be really time consuming. I want to load the db file into memory, and execute select * from XXX in memory. Is it possible to do it? Many thanks!

Upvotes: 2

Views: 1101

Answers (2)

Benoit
Benoit

Reputation: 79185

you could still do the following:

sqlite database < script

with script containing:

.output dump.sql
.dump
.output.stdout

then start an SQLite shell w/o any argument, and do .read 'dump.sql'

Upvotes: 0

BastiBen
BastiBen

Reputation: 19870

Technically the database is loaded into memory when you open it. But you can have pure memory-based databases, too. In that case use :memory: as the path when opening the database.

Hope that helps. :)

Upvotes: 1

Related Questions