Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Sqlite
Qt 6.11 is out! See what's new in the release blog

Sqlite

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dstudentx
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dstudentx
        wrote on last edited by
        #3

        hmmmm I thought I was opening the database

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dstudentx
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dstudentx
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved