I want to preload 9000 records via either a file or a whatever is best. The idea is I want to have there 9000 records somewhere and I want to load them into a sqlite DB via phonegap. I have all this working other then loading the data from somewhere. Here is what i have so far
I have a file records.csv file and here is my code
function populate_events_from_csv(db){
var event_data;
$.ajax({
type: "GET",
url: "records.csv",
dataType: "text/csv",
error: function (request, status, error) {
console.log('fail');
console.log(request.responseText);
},
success: function(data) {
console.log('success');
event_data = $.csv.toObjects(data); }
});
console.log(event_data);
db.transaction(function(tx) {
var q = 'INSERT INTO Events (id, name) VALUES (?, ?)';
_(event_data).each(function(row) {
tx.executeSql(q, [row.id, row.name]);
});
});
}
This approach would work but it fails because of the double and single quotes in the records csv
If anyone sees what i am doing wrong or another solution to initially inserting these 9000 records