storesafe / cordova-sqlcipher-adapter

A Cordova/PhoneGap plugin to create and access encrypted databases on Android, iOS, and Windows with API similar to HTML5/Web SQL API
Other
89 stars 55 forks source link

file is not a database: , while compiling: select count(*) from sqlite_master; #92

Closed suriyacs closed 4 years ago

suriyacs commented 4 years ago

Hi

I have trying to integrate cordova-sqlcipher-adapter for my ionic3 hybrid mobile app. while trying to open connection for android device to the database i have received "Could not open a connection error" I have debugged inside an plugin and found file is not a database: , while compiling: select count(*) from sqlite_master;

I don't know what's wrong in my code Here my connection details i have submitted for reference

createConnection({ type: 'cordova', database: this.dbName, location: 'default', logging: ['error', 'schema'], synchronize: false, entities, migrations, migrationsRun: true, extra: { key: "test" } });

Have used typeorm for the connection

Here https://github.com/typeorm/typeorm/pull/1272 they have mentioned extra option will be used to set the key.

trying to encrypt ionic native sqlite database

Can you let me know what should l change!?

brodycj commented 4 years ago

I have not been actively testing with Ionic3 or TypeORM. I would highly recommend that you post an app with a minimal, reproducible example ([1]) to demonstrate the observed behavior so that others can help take a look.

[1] https://stackoverflow.com/help/minimal-reproducible-example

brodycj commented 4 years ago

Closing due to lack of minimal reproducible example.

jkufrin commented 4 years ago

I was getting this error after migrating from regular SQL to SQLCipher. It turns out that Android backups DBs and on re-install was restoring the old one, while Ionic was creating the new one. This fix worked for me. https://stackoverflow.com/a/54997687/6321055