How to check pragma key is correct or incorrect? #3332
-
I initially thought I could run a query to check if the entered key is correct. However, I was surprised to learn that the database only attempts to open once. If the key is incorrect, it throws an error and saves that state, preventing any further attempts—even if the correct key is entered afterward. Is there any way to check whether the key is correct or incorrect multiple times without this limitation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
If an error happens while opening the database, we can't generally know what state the database is in and what still needs to happen to make it ready (e.g. with migrations). Also, we want to avoid hiding errors (if you catch the first error or push it somewhere or if it happens in a stream where errors might not be handled properly, the error should still be visible). As long as the open operation doesn't throw, you should be fine. So you could try to apply |
Beta Was this translation helpful? Give feedback.
-
Is there a simpler way to handle the passcode entry process? Currently, once the passcode is entered, there's no way to retry unless the app is restarted. Could you explain this process in a bit more detail? What I'm aiming to do is set up a backup system using this passcode. Here's the flow: 1- The user enters the database passcode. Now, to access this file, we need the passcode again. This is where I'm encountering the need for a check—essentially, a way to verify the passcode without requiring a restart of the app each time. How can we streamline this process? |
Beta Was this translation helpful? Give feedback.
Your snippet didn't use the temporary database, did you do something like this / did that find the wrong key?