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.
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.
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.
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.
Check out this example: Loading and Saving In-Memory Databases
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With