Skip to content

In Encrypted database, How to check whether the db connection is succesful or not ? #1502

Answered by simolus3
rajagopalx asked this question in Q&A
Discussion options

You must be logged in to vote

You could add a simple statement accessing the database in the setup callback, like this:

setup: (rawDb) {
  rawDb.execute("PRAGMA key = 'wrongpassword';");
  
  try {
    rawDb.execute('PRAGMA user_version;');
  } on SqliteException catch (e) {
    if (e.resultCode == 26) {
      // not a database, the password is probably wrong
    }
  }
},

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rajagopalx
Comment options

Answer selected by rajagopalx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants