Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving to disk an in-memory database

I made a database through sqlite in c++.

The db has been created in memory (using the ":memory:" parameter insted of a filename), in order to have a very quick behavior.

The database is created by the following lines:

sqlite3* mem_database; if((SQLITE_OK == sqlite3_open(":memory:", &mem_database)){     // The db has been correctly created and     // I can do some stuff with it. } sqlite3_close(mem_database); 

My problem is: how can I write the in-memory database to disk? (through c/c++ of course).

I read something about the ATTACH and DETACH sqlite commands, but I can get them working only with the sqlite interactive shell (not from c/c++ code).

Greets.

like image 747
Giancarlo Avatar asked Sep 17 '09 07:09

Giancarlo


People also ask

Is database a memory or disk?

An in-memory database keeps all data in the main memory or RAM of a computer. A traditional database retrieves data from disk drives. In-memory databases are faster than traditional databases because they require fewer CPU instructions. They also eliminate the time it takes to access data from a disk.

What is on disk and in-memory?

an on-disk database stores the data on disk and uses memory for caching. Of course, we all know memory (RAM) is much (multiple order of magnitude) faster than disk, so the advantage of an in-memory database is clear.

What is an in-memory data store?

In-memory databases are purpose-built databases that rely primarily on memory for data storage, in contrast to databases that store data on disk or SSDs. In-memory data stores are designed to enable minimal response times by eliminating the need to access disks.


1 Answers

Check out this example: Loading and Saving In-Memory Databases

like image 164
Nick Dandoulakis Avatar answered Oct 05 '22 13:10

Nick Dandoulakis