Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Sqlite

    QML and Qt Quick
    2
    6
    1552
    Loading More Posts
    • 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
      dstudentx last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • D
          dstudentx last edited by

          hmmmm I thought I was opening the database

          1 Reply Last reply Reply Quote 0
          • D
            dstudentx last edited by

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

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • D
                dstudentx last edited by

                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 Reply Quote 0
                • First post
                  Last post