Forum > Databases

Pointing TSQLite3Connection.DatabaseName to a "file" in memory.

(1/1)

r.lukasiak:
Hi everyone,

I have an encrypted SQLite file provided with my app, the app is decrypting it OnCreate. I used TMemoryStream and DCPciphers to do it. The decrypted "file" is in memory, how can I point TSQLite3Connection.DatabaseName to it? Is there any way to do so? I know about :memory: but it still doesn't solve my problem.
I found this post: https://forum.lazarus.freepascal.org/index.php?topic=17479.0 but this solution requires saving the decrypted database to a file and then loading it back. I'd rather use it directly from RAM. The DB is only for SELECT, nothing will be INSERTed or UPDATEd so there is no need to save anything to a file.

any idea?

Thanks in advance!

PierceNg:
The description for sqlite3_deserialize sounds like it meets your use case. I don't see Pascal FFI definition for sqlite3_deserialize() in current FPC SQLite3 bindings, so you'll have to add it in your own code.

Zvoni:

--- Quote from: PierceNg on August 12, 2022, 02:48:05 am ---The description for sqlite3_deserialize sounds like it meets your use case. I don't see Pascal FFI definition for sqlite3_deserialize() in current FPC SQLite3 bindings, so you'll have to add it in your own code.

--- End quote ---
Probably has to do with, that the Header-Definitions for SQLite are Version 3.14
and with SQLite 3.36 they changed the compile-option from opt-in to opt-out
Meaning: Before 3.36 you had to include explicitely -DSQLITE_ENABLE_DESERIALIZE when compiling SQLite, so probably 99% of the users didn't have the interface in their library ("of-the-shelf library")
With 3.36 and later, deserialize is compiled in per default

I've already asked a few times, if there will be an update to the SQLite-Bindings

Navigation

[0] Message Index

Go to full version