Skip to content

Unable to get createFromLocation option working for Windows #491

Open
@xenown

Description

@xenown

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:

Debug logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions