简体   繁体   English

是否可以从现有的内存块创建内存中的SQLite数据库?

[英]Is it possible to create an in-memory SQLite database from an existing chunk of memory?

From the documentation it looks like this is not possible, but I want to be sure. 从文档看起来这是不可能的,但我想确定。 Here's my use case: 这是我的用例:

I want an encrypted database. 我想要一个加密的数据库。 It should only be decrypted while it is in memory (while the program is running). 它只应在内存中解密(程序运行时)。 The only way I can see to do this would be to decrypt a file from disk before handing it off to SQLite. 我能看到这样做的唯一方法是在将文件交给SQLite之前从磁盘解密文件。 But I cannot find any way to give SQLite a pointer and say, "Here, this is a database." 但我找不到任何方法给SQLite一个指针并说:“这里,这是一个数据库。” Nor can I find a way to serialize an in-memory database and then encrypt it before writing to disk. 我也找不到一种方法来序列化内存数据库,然后在写入磁盘之前对其进行加密。 I assume the sqlite3_backup API would need an unencrypted database file? 我假设sqlite3_backup API需要一个未加密的数据库文件?

I'm running on Android, so I'd like to use the built-in SQLite and I don't think it will be possible to install SQLite Encryption Extension (SEE) . 我在Android上运行,所以我想使用内置的SQLite,我认为不可能安装SQLite加密扩展(SEE) (Running on Android also means I don't have full access to the C++ API, but we can ignore that for now). (在Android上运行也意味着我没有对C ++ API的完全访问权限,但我们现在可以忽略它)。

Since you can replace the functions sqlite uses to interact with the filesystem from the application using the sqlite_vfs_register method, it should be possible. 由于您可以使用sqlite_vfs_register方法替换sqlite用于与应用程序中的文件系统交互的函数,因此应该可以。 I don't have experience with the encryption extension, but there is a chance that it uses this interface too, so it might be even possible to use it. 我没有加密扩展的经验,但它也有可能使用这个接口,因此甚至可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM