Hi is there any way to do a bulk insert in the SQLite in React-native?
I am using the following library
https://github.com/andpor/react-native-sqlite-storage
I have tried the following code but it just inserts all the values to the first column in the table.
export function saveWelfareInfo(authenticationToken, welfareArr) {
var sqlQuery = 'authenticationToken, enabled, title, tabname, tabimage, tabcontents, last_update_date, id, ethnicity_id, course, campus, app_profile_id'
let db = OpenSqliteDatabase()
db.transaction((tx) => {
tx.executeSql('insert into welfare_list(' + sqlQuery + ') values(?,?,?,?,?,?,?,?,?,?,?,?)', welfareArr)
tx.executeSql('SELECT * FROM welfare_list', [], (tx, results) => {
console.log("Query completed");
var len = results.rows.length;
for (let i = 0; i < len; i++) {
let row = results.rows.item(i);
console.log('welfare_list Record: ', row);
}
});
})
Any help would be greatly appreciated. thanks in advance
Don't worry solved the issue. used the following page as example.
https://github.com/reconka/Cordova-sqlite-storage-bulkinsert/blob/9e72c4ca44dd56df38233dbda42fcc6de80363d4/android/assets/www/js/index.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With