andpor / react-native-sqlite-storage

Full featured SQLite3 Native Plugin for React Native (Android and iOS)
MIT License
2.76k stars 520 forks source link

No such table #459

Closed swaroopaillinda closed 3 years ago

swaroopaillinda commented 3 years ago

Hi

I am creating a database and created table in sqlite ide and exported that db file to my android folder in assets/www but when executing a select query I am not getting the data its returning 0 rows import {openDatabase} from 'react-native-sqlite-storage'; const db = openDatabase({name: 'user_db.db', createFromLocation: 1}); db.transaction(function (txn) { txn.executeSql( "SELECT Year FROM sqlite_master WHERE type='table' AND name='tbl_user'", [], function (tx, res) { console.log('item:', res.rows.length); if (res.rows.length == 0) { console.log("NO DATa") // txn.executeSql('DROP TABLE IF EXISTS tbl_user', []); // txn.executeSql( // 'CREATE TABLE IF NOT EXISTS tbl_user(user_id INTEGER PRIMARY KEY AUTOINCREMENT, user_name VARCHAR(20), user_contact INT(10), user_address VARCHAR(255))', // [], // ); }else{ console.log("DTAAAAA>>>",res.rows) } }, ); });

can anyone tell me how to get table data from prepopulated database in this.

andpor commented 3 years ago

Please provide precise information and follow the defect reporting framework. Format code samples.