Using the SQLite Online Backup API

Hello @classintouch - thanks for taking a look at SQLCipher. Historically the backup API has not been supported with SQLCipher, with the preferred approach being use of an attached database to copy back and forth, or the use of sqlcipher_export(). That said, we’d need to take a closer look into this in order to determine what is causing the crash, and whether this use case could be supported.

In the mean time, one option / workaround would be to open your in memory database and then attach the encrypted database.

Once you have the database attached you could copy data from the attached database into the memory database, e.g. insert into X select * from attached.X (assuming the same schema).

The final thing that I would mention is that SQLCipher is typically not used in the manner you are describing, in terms of copying all data from an encrypted database into memory. SQLCipher performs cryptographic operation on a page-by-page basis, so there is no need to decrypt the entire database and load it into memory, except for very special circumstances. In most cases, leaving the database on disk, increasing the page cache and taking note of design guidelines for performance will yield good speed even for encrypted databases.