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

Error while opening the database on React 0.71.2

Open alejandro-devop opened this issue 2 years ago • 2 comments

Error while opening the database on React 0.71.2

Expected Behavior

Open the database as expected

Current Behavior

image

Possible Solution

I'm not sure of what can be done to solve this

Steps to Reproduce (for bugs)

Just follow the instructions in the readme file.

Context

Cannot use the library with the latest version of react-naive.

Your Environment

  • React Native SQLite Storage Version used: 6.0.1
  • React Native version used: 0.71.2
  • Operating System and version (simulator or device): Device and simulator
  • IDE used: Visual studio code.
  • Link to your project:

Debug logs

 LOG  Running "SQLiteApp" with {"rootTag":1,"initialProps":{}}
 LOG  Queries:  ["CREATE TABLE IF NOT EXISTS todos ( name TEXT NOT NULL, description TEXT, isCompleted INTEGER )"]
 LOG  Error:  [TypeError: Cannot convert null value to object]
Process terminated. Press <enter> to close the window

Note: I got another project using react-native 0.69.5, and the library works as expected, what leads me to think it's only happening with the latest version of react-native, the following is an output executing a query (With wrong syntax sorry) on react-native 0.69.5.

image

alejandro-devop avatar Feb 09 '23 03:02 alejandro-devop

Hello @alejandro-devop, I've finally found a solution working for me (RN 0.71.3). Hope it helps:

  • uninstall app (I guess that's this step which saved me)
  • make sure you followed install instructions for your supported platform (this link could help you)
  • make sure (with DBBrowser for SQLite for example) that your db file is OK
  • use this code to open your database => openDatabase({ name: 'filename.db', createFromLocation: 1, location: 'Library'})
  • do not hesitate to clear and re-add your db file in the native projects just to be sure
  • reinstall app

Should be working now

leonardoballand avatar Feb 19 '23 17:02 leonardoballand

@alejandro-devop did you find any solution?

ThushalIntervest avatar Jul 17 '23 05:07 ThushalIntervest