I am using https://github.com/andpor/react-native-sqlite-storage for importing prepopulated data and these were my steps for setting it up:
1. npm install --save react-native-sqlite-storage
2. cd ios && pod install && cd ..
3. created 'www' folder and inserted 'users.db' in it. Then I added 'www' to my projectFolder as instructed
4. For android, I created an 'assets' folder in src/main and inserted the 'users.db' file into it.
However, I'm encountering an error where it says there is SQL ERROR: {"no such table: users", code 5}
I've tried multiple styles but to no avail.
import SQLite from 'react-native-sqlite-storage';...let db;...function loadAndQueryDB() { //db = SQLite.openDatabase({ name: './users.db', createFromLocation: 1,}, openCB, errorCB); //db = SQLite.openDatabase({ name: 'users.db', createFromLocation: 1,}, openCB, errorCB); //db = SQLite.openDatabase({ name: 'users', createFromLocation: 1,}, openCB, errorCB); queryUsers(db);}function queryUsers(db) { db.transaction((tx) => { tx.executeSql('SELECT * FROM users', [], queryUsersSuccess, errorCB); }); }
My database has a table 'users' in it.
I'm not sure what the issue is and how to address it. Thanks!
EDIT: So I figured that
db = SQLite.openDatabase({name : "users.db", createFromLocation : 1}, openCB, errorCB);
Is opening from Library/Developer/CoreSimulator/Devices/.../LocalDatabase
How do I change where openDatabase is opening from?