SQL with WebAssembly
-
wrote on 2 Sept 2019, 06:02 last edited by
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?
-
Hi,
AFAIK, the QtSql module is currently not available for web assembly.
@lorn-potter might be able to shed some more light on it.
-
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?
wrote on 2 Sept 2019, 07:20 last edited by JonB 9 Feb 2019, 07:21@infinity , @SGaist
I asked this recently See the response I got at https://forum.qt.io/topic/105944/qt-for-webassembly-widget-example-gone/181.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.
-
wrote on 2 Sept 2019, 19:57 last edited by lorn.potter 9 Feb 2019, 20:00
Someone has ported sqlite to wasm...
https://github.com/fluencelabs/sqliteYou 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. -
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?
-
wrote on 21 May 2021, 15:02 last edited by
No. I switched from MySQL to SQLite.
-
Hi,
AFAIK, the QtSql module is currently not available for web assembly.
@lorn-potter might be able to shed some more light on it.
wrote on 27 Mar 2024, 13:02 last edited by 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-modulesBecause 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:
-
@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-modulesBecause 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:
@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.
-
@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.
Lifetime Qt Championwrote on 27 Mar 2024, 22:49 last edited by Christian Ehrlicher@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. 😉