Copying all the contents from the source table We create a in-memory database, 'attaching' it with the disk based SQLite databaseĭb.SQLExecute("attach database ':memory:' as 'RAMDB'") Re.Reason = "Error trying to connect to the database"ĭb.SQLExecute("PRAGMA LOCKING_MODE = Exclusive") // Improves the read access to the database However, and focusing on the tip itself, this is the snippet of code you can use: Dim db as SQLiteDatabase = New SQLiteDatabaseĭb.DatabaseFile = // FolderItem to the SQLite database file on diskĭb.EncryptionKey = "aes256:" + // same password that the one used to encrypt the data You can further modify this technique so you can work with your databases in a mixed way that is, where we want to simultaneously execute a query involving both an encrypted database table and an in-memory table database.īut for this example code we are only focused on opening an encrypted SQLite database (based on disk) as a new SQLite class instance, and using next a SQL sentence to create a new in-memory database (named RAMDB in the example), creating the same table on the RAM database next and then copying the data from the source table during the process.įrom that time on, you will be able to use the new table on RAM at light speed!Īnother SQL command you might find of interest, and that you can use in all your SQLite databases where you expect to get a gain in the read speed, is to use the exclusive mode, using for that PRAGMA LOCKING_MODE = Exclusive. How can we improve this? One technique is the creation of a new in-memory based SQLite database, where we will be able to copy the table (or tables) we are interested in getting the maximum speed possible with. But the truth is that encrypting the data in these databases can introduce a penalty in our queries, both from read and writing/updating data to them. It’s very usual to use encrypted SQLite databases in our Xojo projects where we expect to get the maximum read speed from them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |