mardi 31 mars 2015

How to use QML to import a CSV to s SQLite database?

I've been programming an app that uses two databases, one of which contains contacts that I've exported from outlook.


I would like to import these into a sqlite database using QML/javascript only.


I have created the table and I'm trying to execute the below commands:



function createTable(database)
{
database.transaction(
function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS staff(id INTEGER PRIMARY KEY AUTOINCREMENT, "First Name" TEXT, "Last Name" TEXT)');
tx.executeSql('.mode csv');
tx.executeSql('".import" "./contacts.csv"');
}
)
}


I haven't got to the .import yet so that is secondary. I'm guessing I must be missing some method that I'm not familiar with.


Any help is appreciated.


Aucun commentaire:

Enregistrer un commentaire