Recent

Author Topic: Pointing TSQLite3Connection.DatabaseName to a "file" in memory.  (Read 584 times)

r.lukasiak

  • Full Member
  • ***
  • Posts: 138
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

  • Sr. Member
  • ****
  • Posts: 373
    • SamadhiWeb
Re: Pointing TSQLite3Connection.DatabaseName to a "file" in memory.
« Reply #1 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.

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: Pointing TSQLite3Connection.DatabaseName to a "file" in memory.
« Reply #2 on: August 12, 2022, 08:24:19 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.
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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

 

TinyPortal © 2005-2018