SQLite memory usage

How does SQLite handle a database loaded from SD Card? Is the whole database loaded into memory? I am assuming every insert, update, delete writes to the SD Card?

Can a small database be loaded from flash into RAM memory then saved back to SD Card when closed?

SQLite does have an in-memory option, but that is typically used with appliances that revert back to a known initial state on reboot. I have never considered saving it, but there must be a way. I suggest though to save not just on close, but every so often, just in case something goes awry…

More info here: https://www.sqlite.org/inmemorydb.html

BOTH way

you can create DB on your pc , and put on SD Card than use it from SD
or you can create in memory and save on DB …

how you like it - check insider sample i posted (how to step by step with sample)

The code below is a simple example that creates a database file in RAM (SD cards and USB drives can be used as well). A table is created, a few rows are filled, and then this data is read from the database. This data is then iterated over and printed out. ColumnOriginNames returns the name of each of the columns.

check on tutorial (on RAM how to use it) / or in insider i posted example how to with SD CARD

1 Like

I don’t see any functions in SQLite to support flushing an in memory database to storage. The closest I can find is SQLite Backup API which is not supported in TinyCLR.

I will just need to make sure I have enough SuperCap capacity to query the in-memory db and save it to SD Database. It’s not the end of the world but it has a direct bearing on the hardware design.