Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Create Table on iOS failure - SQLITE.ExecSQL Failed Prepare: 1 #43

Closed
johnnyzen opened this issue Mar 8, 2017 · 7 comments
Closed

Create Table on iOS failure - SQLITE.ExecSQL Failed Prepare: 1 #43

johnnyzen opened this issue Mar 8, 2017 · 7 comments

Comments

@johnnyzen
Copy link

johnnyzen commented Mar 8, 2017

Hi there

Getting this error on iOS only (Android is fine)

When I try to create:

this.sqlite = new Sqlite(this.databaseName, (err, db) => {
console.log("DB");
            if (err) {
                console.log("Error: " + err);
            }

            console.log("Database opened");

            db.execSQL('create table test (`int_field` integer);', function(err) {
                if (err) {
                    console.log("!---- Create Table err", err);
                    return;
                }
            });

I am getting the error:

!---- Create Table err SQLITE.ExecSQL Failed Prepare: 1

Any ideas what this might mean?

@NathanaelA
Copy link
Owner

Thanks for the report; I will take a look into this; but to set your expectation it probably won't be for a while as I always prioritize my commercial customers over free support.

Also if you want to debug it and send me a pull request; I'm always glad for pull requests.

@Christopotamus
Copy link

Have you figured this out yet @johnnyzen?

Could it be the backticks in your 'create table' string? Backticks in es6 are used for string interpolation, and I noticed some oddities with string interpolation in my own app. Maybe try building the string separately and passing it to execSQL as a parameter.

@jibon57
Copy link

jibon57 commented May 31, 2017

I am getting this error:

CONSOLE ERROR file:///app/services/commonServices.js:20:30: We failed to open database ReferenceError: Can't find variable: sqlite3_open_v2
CONSOLE ERROR file:///app/tns_modules/@angular/core/./bundles/core.umd.js:1091:24: ERROR Error: Uncaught (in promise): ReferenceError: Can't find variable: sqlite3_open_v2
	file:///app/tns_modules/nativescript-sqlite/sqlite.js:103:40
	ZoneAwarePromise@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:776:37
	Database@file:///app/tns_modules/nativescript-sqlite/sqlite.js:90:23
	CommonService@file:///app/services/commonServices.js:18:19

But it's fine from Android.

@dotnetdreamer
Copy link

i was having the same problem. It turns out i was missing closing ) in my sql statment. like following:
db.execSQL("CREATE TABLE IF NOT EXISTS setting (id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, value TEXT)")

@NathanaelA
Copy link
Owner

I have tested all the existing and new functionality in the new 2.x release. I am not able to duplicate either of these issue reported in this report.

Please note, one of the issues above is because you didn't fully rebuild the app (ios). You MUST de-install the app from the device, then do a tns platform clean ios then do a tns run ios.

@richard-slabbert94
Copy link

Sorry to ask a question in a closed thread, but I also came across this issue with my app: "SQLITE.ExecSQL Failed Prepare: 1" with one of my insert statements.

Platform: iOS
Using the "ad-hoc" method of distribution (ie I am not using the nativescript cli)
iOS version: 12.4.7
NativeScript version: 6.7.4
nativescript-sqlite version: 2.3.3

Like you said @NathanaelA - it works fine if I uninstall the app before installing it again on the device. However, if I update the existing install without removing the app first I get that error. I don't really want to ask the users to completely uninstall the app each time they want to update, plus I am not sure if the app will pass the app store review if that is required in order for the app to function correctly.

So my question is whether there is a possible resolution to this problem in the pipeline or if there is something I can do to mitigate this? Also, most importantly, what is the reason for the need to reinstall completely?

Thank you again, @NathanaelA, for a great plugin! I hope I made myself clear?

All the best :)
Richard

@richard-slabbert94
Copy link

Excuse me. I see it was an issue on my side. Sorry to worry you.

Thanks,
Richard

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

No branches or pull requests

6 participants