Description
I'm trying to open an existing database using the createFromLocation option, but I just can't get it to work. I've tried
openDatabase({ name: "test", location: 'default', createFromLocation: "1" },
() => { console.log("db load success!") }, (e) => { console.error("db load failure!"); console.error(e); console.error(e.code) });
which results in the error message being written. The error printed was "Error: Could not open database" followed by a stack trace. I have saved my sqlite file in D:\appname\windows\appname\www
and have updated the visual studio solution to "Include In Project" the db file.
I have also tried
openDatabase({ name: "test", location: 'default', createFromLocation: "~Assets/test.sqlite" },
() => { console.log("db load success!") }, (e) => { console.error("db load failure!"); console.error(e); console.error(e.code) });
which gives the same error.
I've made sure to follow the 4 windows specific setup steps listed on the repo README.
For what its worth, I've been compiling my app only through npx react-native run-windows
.
Have I missed a step somewhere?
Expected Behavior
I'd expect the database file to be read.
Current Behavior
It's unable to read the file.
Possible Solution
Steps to Reproduce (for bugs)
Try createFromLocation option with React Native Windows.
Context
Your Environment
- React Native SQLite Storage Version used: 3
- React Native version used:
react-native: 0.66.0-rc.1 => 0.66.0-rc.1
react-native-windows: 0.66.0-preview.6 => 0.66.0-preview.6 - Operating System and version (simulator or device): Windows 10 10.0.19042
- IDE used: Visual Studio
- Link to your project: