Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlcipher compatibility #1298

Open
DeHby opened this issue May 21, 2024 · 2 comments
Open

Sqlcipher compatibility #1298

DeHby opened this issue May 21, 2024 · 2 comments

Comments

@DeHby
Copy link

DeHby commented May 21, 2024

I have compatibility problems when using sqlcipher with sqlite_orm

image

When dealing with the sqlite3_key problem, I used the on_open method to solve it.

But if I use pragma, it will get an error.

image

The reason for the failure is that the callback of on_open precedes set_pragma.

I hope to add "before" and "after" callbacks for compatibility or other better ways.

@trueqbit
Copy link
Collaborator

What's the error you encounter?

@DeHby
Copy link
Author

DeHby commented May 22, 2024

What's the error you encounter?

The call of sqlite3_key is in the callback of on_open, but set_pragma precedes it.

Because the database has been encrypted by SQLCipher, you need to execute sqlite3_key before you can execute set_pragma("journal_mode ").

Otherwise, SQLITE will not be able to decrypt the DB file correctly, recognize the header of SQLite, and prompt the error "file is not a database".

My current solution is to put the on_open function call at the front of the on_open_internal function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants