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

dbstat virtual table is not available on Android

Open oleksandr-dziuban opened this issue 6 years ago • 1 comments

Virtual dbstat table is not available on Android, but iOS works fine.

SELECT SUM("pgsize") FROM "dbstat" WHERE name='<any existing table name>'

Expected Behavior

This query should return calculated size in bytes for this table on Android.

Current Behavior

Database throws an error:

query failed:  SELECT SUM("pgsize") FROM "dbstat" WHERE name='<any existing table name>'
"no such table: dbstat (code 1 SQLITE_ERROR): , while compiling: SELECT SUM("pgsize") FROM "dbstat" WHERE name='<any existing table name>'"

Possible Solution

Enable compile option SQLITE_ENABLE_DBSTAT_VTAB=1 for SQLite on Android

Steps to Reproduce (for bugs)

  • Use latest [email protected]
  • Install react-native-sqlite-database (i'm using it with TypeORM)
  • Run query: SELECT SUM("pgsize") FROM "dbstat" WHERE name='<any existing table name>'

Your Environment

  • React Native SQLite Storage Version used: 4.1.0
  • React Native version used: 0.61.2
  • Operating System and version (simulator or device): MacOS 10.14.6 or MacOS 10.15
  • IDE used: WebStorm
  • Link to your project: under NDA

Debug logs

ExceptionsManager.js:118 query failed:  SELECT SUM("pgsize") FROM "dbstat" WHERE name='templateConfiguration'
"no such table: dbstat (code 1 SQLITE_ERROR): , while compiling: SELECT SUM("pgsize") FROM "dbstat" WHERE name='<any existing table name>'"

Could you please guys advice a workaround maybe how to get table size in bytes for Android? This solution works fine fo iOS, but not for Android. I s it possible to enable dbstat virtual table for Androids too? Thanks a lot

oleksandr-dziuban avatar Oct 27 '19 13:10 oleksandr-dziuban

I am not sure but can you please try to see the database in Android Studio? You can find any clue if it is creating the table in the DB or not? Here is the way you can see the database in Android Studio How to See SQLite Database Data Saved in Device using Android Studio

SnehalAgrawal avatar Dec 03 '19 09:12 SnehalAgrawal