Skip to content

uSQLite running on RAM (in memory) #27

@beyonlo

Description

@beyonlo

Hello, thank you for the great project.

I would like to use the uSQLite on the ESP32-S3 (8MB RAM, 32MB Flash), where the uSQLite database will have ~4MB. So to be faster the idea is to load all database to the RAM, and get (the selects) to the RAM database, and when need to write data (insert/update), write on disk database, syncing with the RAM database.

Is possible to copy entire database to the RAM and use uSQLite on RAM e when needed insert/update data, write that specific data to disc, like SQLite support?

Should be like this (https://stackoverflow.com/a/53253110):

import sqlite3

source = sqlite3.connect('existing_db.db')
dest = sqlite3.connect(':memory:')
source.backup(dest)

and/or this (https://stackoverflow.com/a/53253110):

# first connection
c1 = sqlite3.connect("file::memory:?cache=shared", uri=True)

# second connection, to the *same database*
c2 = sqlite3.connect("file::memory:?cache=shared", uri=True)

# third connection, to a different database altogether
c3 = sqlite3.connect('/tmp/sqlite3.db', uri=True)
# can attach to the shared in-memory database, but only if you used
# uri=True on the original connection
c3.execute("ATTACH DATABASE 'file::memory:?cache=shared' AS inmem")

Thank you in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions