question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’ve been looking for someone with the same problem, but I couldn’t find any that could resolve mine.

I’m getting success on SQLite.openDatabase but tx.executeSql throws me No such table

If I run the query at SQLiteStudio it work normally

SELECT * FROM `development`.`transaction`;
SELECT id FROM `transaction`;
SELECT * FROM sqlite_master;

Follow my setup:

.../android/app/src/main/assets/www/development
import SQLite from 'react-native-sqlite-storage'

    ...

    const successcb = (response) => {
      console.log(`success`, response)
    }

    const errorcb = (response) => {
      console.log(`error`, response)
    }

    const db = SQLite.openDatabase({
      name: 'development',
      createFromLocation: 1
    }, successcb, errorcb)

    db.transaction((tx) => {
      tx.executeSql('SELECT * FROM `transaction`', [], (tx, results) => {
      // tx.executeSql('SELECT * FROM `development`.`transaction`', [], (tx, results) => {
      // tx.executeSql('SELECT * FROM sqlite_master', [], (tx, results) => {
        console.log(`results:`, results.rows)
      })
    })

The error

I/ReactNativeJS: 'success', { openargs: 
{ name: [Getter/Setter],
    createFromLocation: [Getter/Setter],
    dblocation: [Getter/Setter],
    assetFilename: [Getter/Setter] },
dbname: 'development',
openSuccess: [Function: successcb],
openError: [Function: errorcb] }
E/SQLiteLog: (1) no such table: transaction
E/unknown:SQLitePlugin: SQLitePlugin.executeSql[Batch]() failed
    android.database.sqlite.SQLiteException: no such table: transaction (code 1): , while compiling: SELECT * FROM `transaction`
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
        at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
        at org.pgsqlite.SQLitePlugin.executeSqlStatementQuery(SQLitePlugin.java:815)
        at org.pgsqlite.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:724)
        at org.pgsqlite.SQLitePlugin.access$100(SQLitePlugin.java:49)
        at org.pgsqlite.SQLitePlugin$DBRunner.run(SQLitePlugin.java:936)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
E/unknown:SQLitePlugin: SQLitePlugin.executeSql[Batch](): failed
    android.database.sqlite.SQLiteException: no such table: transaction (code 1): , while compiling: SELECT * FROM `transaction`
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
        at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
        at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
        at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
        at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
        at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
        at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1318)
        at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1257)
        at org.pgsqlite.SQLitePlugin.executeSqlStatementQuery(SQLitePlugin.java:815)
        at org.pgsqlite.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:724)
        at org.pgsqlite.SQLitePlugin.access$100(SQLitePlugin.java:49)
        at org.pgsqlite.SQLitePlugin$DBRunner.run(SQLitePlugin.java:936)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

I/ReactNativeJS: 'Error handler not provided: ', { message: 'no such table: transaction (code 1): , while compiling: SELECT * FROM `transaction`', code: 0 }

My tx

{ db: 
    { openargs: 
    { name: [Getter/Setter],
        createFromLocation: [Getter/Setter],
        dblocation: [Getter/Setter],
        assetFilename: [Getter/Setter] },
    dbname: 'development',
    openSuccess: [Function: successcb],
    openError: [Function: errorcb] },
fn: [Function],
error: undefined,
success: undefined,
txlock: true,
readOnly: false,
executes: [] }
SELECT * FROM sqlite_master; // 0 rows
"react": "16.0.0",
"react-native": "^0.49.3",
"react-native-sqlite-storage": "^3.3.3"

Emulator Nexus 6 API 25

If I run CREATE TABLE twice, it will throw that the table already exists, but it’s not on the file.

What could I be missing?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

10reactions
hyumuscommented, Aug 26, 2019

SQLite.openDatabase({name:“testDB.sqlite3”,createFromLocation:1,location:‘Library’}) . this solved my problem. testDB.sqlite3 file size is 24 MB. testDB.sqlite and testDB.db not working, but testDB.sqlite3 is working.

1reaction
rochapablocommented, Oct 12, 2017

https://github.com/andpor/react-native-sqlite-storage/issues/122#issuecomment-277379594 solve my problem!

const db = SQLite.openDatabase({
  name: 'a',
  ...
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - "no such table" exception - Stack Overflow
To fix this error just change "django.contrib.admin" in INSTALLED_APPS to "django.contrib.admin.apps.SimpleAdminConfig" , it will prevent "django.contrib.admin" ...
Read more >
error - no such table - Using Django
I'm trying to make an e-mail authorization and get an error when creating superuser. What's wrong? application 'www' models.py. from django.
Read more >
django.db.utils.OperationalError: no such table abc
OperationalError: no such table: myApp_tableStatus. The table tableStatus exists in my models.py. Any ideas what I can do to fix this ...
Read more >
SQLite 'no such table: json_each' error during notification check
Opened from the Prefect Public Slack Community niko: Hi, we just witnessed an error when running a prefect task locally on a windows...
Read more >
r/flask - sqlalchemy.exc.OperationalError: (sqlite3 ... - Reddit
The error is telling you exactly what the problem is, the table books does not exist. You have declared a model, but never...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found