[Error: file is not a database] on iOS 17

SQLCipher 4.5.5

Get error SQLITE_NOTADB from
sqlite3_exec(database, (const char*) “SELECT count(*) FROM sqlite_master;”, NULL, NULL, NULL);

But I can open the .sqlite file manually and run the above sql without any problem.

here’s the Stack

That error indicates that you are attempting to do one of the following:

  1. open an encrypted database without a key;
  2. open an encrypted database but the key material is incorrect;
  3. provide a key to open a non-encrypted database (note that “keying” an unencrypted database does not encrypt it, see How to encrypt a plaintext SQLite database to use SQLCipher (and avoid “file is encrypted or is not a database” errors)); or
  4. open a database using a mismatched major version of SQLCipher (e.g. a 3.x database with 4.x or vise versa see Upgrading to SQLCipher 4)

Thanks, but the database is encrypted since I need to enter a password to open the .sqlite.

And the database is created and opened with same SQLCipher (tried v3.4.2 and v4.5.5)

What I see is:

  1. sqlite3_key returns SQLITE_OK
  2. Then get error 26 from
    sqlite3_exec(database, (const char*) “SELECT count(*) FROM sqlite_master;”, NULL, NULL, NULL);

Any idea? Thanks in advance

How exactly are you opening the .sqlite file “manually” and entering the password?

You shouldn’t be able to open the same database using both v3.4.2 and v.4.5.5 with the default settings. They use different encryption properties that make them incompatible by defaults. We need details on how exactly you are opening the files, exact programs, commands, etc.