B4J Code Snippet Clone SQLite Database to SQLite Memory Database

This is a prototype I wrote a while back that takes a source SQLite database and clones it to another SQLite database - in this case an in memory SQLite database.

The code is prety straight forward, initialize the source (from) and destination (to) SQLite databases and call the CopySQLiteDB sub.

NOTE this can be used to clone to a regular SQLite DB as well.

B4X:
    Dim src_db As SQL
    Dim dest_db As SQL
 
    src_db.InitializeSQLite(File.DirApp,"report.sqlite",False)
    dest_db.InitializeSQLite("", ":memory:",True)
 
    DBUtils.CopySQLiteDB(src_db,dest_db)

You can then use the dest_db SQL object as per normal.
 

Attachments

  • SQLite_ToMemory.zip
    2.2 KB · Views: 124
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
Quite useful code indeed. Thanks!
Maybe Erel might add it to the DBUtils library.
 
Top