Store website data in database
Unsolved
Qt WebKit
-
How do i get the data "message" from my website into the database with the command "insert into ..."?
#include <QCoreApplication>
#include <QWebSocket>
#include <QtSql>
#include <QtDebug>
#include <QSqlError>
#include <QSqlDatabase>
#include <QSqlQuery>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);// Datenbank: QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); QSqlQuery q; db.setDatabaseName("Databasename"); if (db.open()) { qDebug() << "Connected"; } else { qDebug() << "Failed"; } //WebSocket: QWebSocket *socket = new QWebSocket(); socket->open(QUrl("ws://IP-Adresse/ws")); QObject::connect(socket, &QWebSocket::connected, [] () { qDebug() << "WebSocket connected"; }); QObject::connect(socket, &QWebSocket::textMessageReceived, [] (const QString &message) { qDebug() << Nachricht: " << message; }); QObject::connect(socket, &QWebSocket::disconnected, [] () { qDebug() << "WebSocket disconnected"; }); //Datenbank: q.exec("INSERT INTO ctrack0 (Daten) VALUES (---Value of message---)"); db.close(); return a.exec();
}