Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SQL with WebAssembly
Forum Updated to NodeBB v4.3 + New Features

SQL with WebAssembly

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 7 Posters 2.1k Views 4 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.
  • I Offline
    I Offline
    Infinity
    wrote on last edited by
    #1

    I would like to compile my application for WebAssembly. The animatedtiles example as described in this article https://blog.qt.io/blog/2019/03/05/using-docker-test-qt-webassembly/ works without any problems. In my application I use the sql module. If I want to compile it I get the following error:

    Info: creating stash file /project/build/.qmake.stash
    cd address/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/address/address.pro ) && make -f Makefile 
    cd user/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/user/user.pro ) && make -f Makefile 
    cd login/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/login/login.pro ) && make -f Makefile 
    Project ERROR: Unknown module(s) in QT: sql
    Makefile:50: recipe for target 'sub-address-make_first' failed
    make: *** [sub-address-make_first] Error 3
    make: *** Waiting for unfinished jobs....
    Project ERROR: Unknown module(s) in QT: sql
    Project ERROR: Unknown module(s) in QT: sql
    Makefile:152: recipe for target 'sub-user-make_first' failed
    Makefile:127: recipe for target 'sub-login-make_first' failed
    make: *** [sub-user-make_first] Error 3
    make: *** [sub-login-make_first] Error 3
    

    Why is the sql module not found?

    JonBJ L 2 Replies Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      AFAIK, the QtSql module is currently not available for web assembly.

      @lorn-potter might be able to shed some more light on it.

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

      8Observer88 1 Reply Last reply
      2
      • I Infinity

        I would like to compile my application for WebAssembly. The animatedtiles example as described in this article https://blog.qt.io/blog/2019/03/05/using-docker-test-qt-webassembly/ works without any problems. In my application I use the sql module. If I want to compile it I get the following error:

        Info: creating stash file /project/build/.qmake.stash
        cd address/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/address/address.pro ) && make -f Makefile 
        cd user/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/user/user.pro ) && make -f Makefile 
        cd login/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/login/login.pro ) && make -f Makefile 
        Project ERROR: Unknown module(s) in QT: sql
        Makefile:50: recipe for target 'sub-address-make_first' failed
        make: *** [sub-address-make_first] Error 3
        make: *** Waiting for unfinished jobs....
        Project ERROR: Unknown module(s) in QT: sql
        Project ERROR: Unknown module(s) in QT: sql
        Makefile:152: recipe for target 'sub-user-make_first' failed
        Makefile:127: recipe for target 'sub-login-make_first' failed
        make: *** [sub-user-make_first] Error 3
        make: *** [sub-login-make_first] Error 3
        

        Why is the sql module not found?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @infinity , @SGaist
        I asked this recently See the response I got at https://forum.qt.io/topic/105944/qt-for-webassembly-widget-example-gone/18

        1.I understand about limitations like no local files, no sub-processes. What about MySQL database access via the Qt classes? Do I assume you cannot have your code access SQL db from browser?

        Not at this point. Although someone has now ported sqlite to wasm, which would be the first step.

        1 Reply Last reply
        2
        • lorn.potterL Offline
          lorn.potterL Offline
          lorn.potter
          wrote on last edited by lorn.potter
          #4

          Someone has ported sqlite to wasm...
          https://github.com/fluencelabs/sqlite

          You could start with that.
          I am unclear if any work on the Qt side would be needed to get Qt compiled with support for sqlite.

          Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
          Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

          1 Reply Last reply
          0
          • I Infinity

            I would like to compile my application for WebAssembly. The animatedtiles example as described in this article https://blog.qt.io/blog/2019/03/05/using-docker-test-qt-webassembly/ works without any problems. In my application I use the sql module. If I want to compile it I get the following error:

            Info: creating stash file /project/build/.qmake.stash
            cd address/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/address/address.pro ) && make -f Makefile 
            cd user/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/user/user.pro ) && make -f Makefile 
            cd login/ && ( test -e Makefile || /usr/local/Qt-5.13.1/bin/qmake -o Makefile /project/source/login/login.pro ) && make -f Makefile 
            Project ERROR: Unknown module(s) in QT: sql
            Makefile:50: recipe for target 'sub-address-make_first' failed
            make: *** [sub-address-make_first] Error 3
            make: *** Waiting for unfinished jobs....
            Project ERROR: Unknown module(s) in QT: sql
            Project ERROR: Unknown module(s) in QT: sql
            Makefile:152: recipe for target 'sub-user-make_first' failed
            Makefile:127: recipe for target 'sub-login-make_first' failed
            make: *** [sub-user-make_first] Error 3
            make: *** [sub-login-make_first] Error 3
            

            Why is the sql module not found?

            L Offline
            L Offline
            Libra
            wrote on last edited by
            #5

            @Infinity Hi, Did you get any solution of this Qt module not found issue while building webassembly project

            1 Reply Last reply
            0
            • I Offline
              I Offline
              Infinity
              wrote on last edited by
              #6

              No. I switched from MySQL to SQLite.

              1 Reply Last reply
              2
              • SGaistS SGaist

                Hi,

                AFAIK, the QtSql module is currently not available for web assembly.

                @lorn-potter might be able to shed some more light on it.

                8Observer88 Offline
                8Observer88 Offline
                8Observer8
                wrote on last edited by 8Observer8
                #7

                @SGaist said in SQL with WebAssembly:

                AFAIK, the QtSql module is currently not available for web assembly.

                I don't understand why is there no the Qt SQL module in this list: https://doc.qt.io/qt-6/wasm.html#supported-qt-modules

                ebaada12-f867-44ea-b791-149c5b5f8333-image.png

                Because QSLite really works on WebAssembly. I ran the next code:

                #include <QtSql/QSqlDatabase>
                #include <QtSql/QSqlError>
                #include <QtSql/QSqlQuery>
                #include <QtSql/QSqlRecord>
                #include "widget.h"
                
                Widget::Widget(QWidget *parent)
                    : QWidget(parent)
                {
                    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
                    db.setDatabaseName("users.sqlite");
                    db.open();
                    qDebug() << db.isOpen();
                    QSqlQuery query;
                    qDebug() << query.exec("create table users_table (id int primary key, nickname varchar(50), score int)");
                    qDebug() << query.lastError();
                    qDebug() << query.exec("insert into users_table values(0, 'John', 5);");
                    qDebug() << query.lastError();
                    QSqlQuery selectQuery("select * from users_table");
                    int idName = selectQuery.record().indexOf("nickname");
                    qDebug() << idName;
                    while (selectQuery.next())
                    {
                        QString name = selectQuery.value(idName).toString();
                        qDebug() << name;
                    }
                    db.close();
                }
                

                It works on WebAssembly:

                acf35ddb-eea9-451b-871f-6f9be2943c53-image.png

                SGaistS 1 Reply Last reply
                0
                • 8Observer88 8Observer8

                  @SGaist said in SQL with WebAssembly:

                  AFAIK, the QtSql module is currently not available for web assembly.

                  I don't understand why is there no the Qt SQL module in this list: https://doc.qt.io/qt-6/wasm.html#supported-qt-modules

                  ebaada12-f867-44ea-b791-149c5b5f8333-image.png

                  Because QSLite really works on WebAssembly. I ran the next code:

                  #include <QtSql/QSqlDatabase>
                  #include <QtSql/QSqlError>
                  #include <QtSql/QSqlQuery>
                  #include <QtSql/QSqlRecord>
                  #include "widget.h"
                  
                  Widget::Widget(QWidget *parent)
                      : QWidget(parent)
                  {
                      QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
                      db.setDatabaseName("users.sqlite");
                      db.open();
                      qDebug() << db.isOpen();
                      QSqlQuery query;
                      qDebug() << query.exec("create table users_table (id int primary key, nickname varchar(50), score int)");
                      qDebug() << query.lastError();
                      qDebug() << query.exec("insert into users_table values(0, 'John', 5);");
                      qDebug() << query.lastError();
                      QSqlQuery selectQuery("select * from users_table");
                      int idName = selectQuery.record().indexOf("nickname");
                      qDebug() << idName;
                      while (selectQuery.next())
                      {
                          QString name = selectQuery.value(idName).toString();
                          qDebug() << name;
                      }
                      db.close();
                  }
                  

                  It works on WebAssembly:

                  acf35ddb-eea9-451b-871f-6f9be2943c53-image.png

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @8Observer8 that's only speculation but it might be:

                  • Because only SQLite is a supported backend and thus claiming that the module itself is supported is misleading
                  • Because the addition is fairly recent and the documentation has not been update
                  • Might be still a tech preview

                  And a flurry of other reasons but again these are speculations.

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

                  Christian EhrlicherC 1 Reply Last reply
                  2
                  • SGaistS SGaist

                    @8Observer8 that's only speculation but it might be:

                    • Because only SQLite is a supported backend and thus claiming that the module itself is supported is misleading
                    • Because the addition is fairly recent and the documentation has not been update
                    • Might be still a tech preview

                    And a flurry of other reasons but again these are speculations.

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by Christian Ehrlicher
                    #9

                    @SGaist and a forth point from the Maintainer Perspective - it was not yet tested because afaik Sqlite gained this feature only recently and we had not yet time to test it esp. since Web Assembly is low priority to me 🙂
                    So it can be said it's working by accident. 😉

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    1

                    • Login

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