Sqlite



  • I've been using the basic demo for using a database see blow. I now need more usage out of my sqlite so I made my own with a sqlite builder but I can't see to use it.

    // What I've been using to learn
    @

    var db = LocalStorage.openDatabaseSync("DB3", "1.0", "The Example QML SQL!", 1000000);
    db.transaction(
    function(tx) {
    tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
    for ( var z=0; z<1000; z++){
    tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'Movie', z ]);
    }
    var rs = tx.executeSql('SELECT * FROM Greeting');
    r=""
    for(var i = 0; i < a; i++) {
    if (i>index_count-1 && up_check ===0)
    r += rs.rows.item(i).salutation + ": " + rs.rows.item(i).salutee + "\t\t"
    ......
    ......
    @
    Now I've created my own sqlite db that I want to use "mydatabase.sql" but I can't seem to get it to work when I

    @
    var db = LocalStorage.openDatabaseSync("mydatabase", "1.0", "The Example QML SQL!", 10000);
    .....
    ......
    .....
    var rs = tx.executeSql('SELECT * FROM film_db');
    .....
    @

    I get this error
    "no such table: film_db Unable to execute statement"
    but film_db is the name of my table when I created the mydatabase.sql

    Please help I'm pulling my hair out on this one.


  • Lifetime Qt Champion

    Hi,

    I am not an expert at all with QML but shouldn't you open mydatabase.sql since it's the name of your database ?



  • hmmmm I thought I was opening the database



  • Doesn't this open the database?
    @
    var db = LocalStorage.openDatabaseSync("mydatabase.sql", "1.0", "The Example QML SQL!", 10000);
    @


  • Lifetime Qt Champion

    Also, are your sure your database contains the missing table ?



  • I'm sure it has the table.

    Where is the database files located? I can't seem to find them on my system, I even checked the md5 of the db name


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.