react-native-sqlite-2 icon indicating copy to clipboard operation
react-native-sqlite-2 copied to clipboard

Error: Queries can be performed using SQLiteDatabase query or rawQuery methods only.

Open ghost opened this issue 6 years ago • 3 comments

I am trying to get column names from table with following code:

db.transaction(txn => {
    txn.executeSql("PRAGMA table_info('table')", [], (txn, res) => {
        console.log(txn, res);
        resolve(res.rows);
    }, (txn, err) => {reject(err)});
});

But I get an exception: Error: Queries can be performed using SQLiteDatabase query or rawQuery methods only.

ghost avatar Sep 10 '19 14:09 ghost

Getting the same error with query WITH one AS ( SELECT 1 ) SELECT * FROM one; (my real query is more complex but this example is enough to trigger an error). Works on iOS, errors out on Android. Both on SQLite 3.29.0, react-native-sqlite-2 version 3.0.1.

@NeliHarbuzava Did you end up finding a workaround?

bbalan avatar Apr 27 '20 00:04 bbalan

SQLiteDatabase db = getWritableDatabase();
        db.execSQL("SELECT * FROM " + TABLE_PRODUCTS);

        Cursor c = db.rawQuery("SELECT * FROM " + TABLE_PRODUCTS, null);
        c.moveToFirst();  

I'm getting the same unknown error (code 0 SQLITE_OK): Queries can be performed using SQLiteDatabase query or rawQuery methods only.

I'm working on it.

antosoa avatar May 17 '20 23:05 antosoa

Getting the same error with query WITH one AS ( SELECT 1 ) SELECT * FROM one; (my real query is more complex but this example is enough to trigger an error). Works on iOS, errors out on Android. Both on SQLite 3.29.0, react-native-sqlite-2 version 3.0.1.

@NeliHarbuzava Did you end up finding a workaround?

This is the exact issue I am running into now, with the WITH clause. Did you ever find a solution to this? I am on Expo-Sqlite 11.0.0

Jacksonishere avatar Nov 01 '23 04:11 Jacksonishere