diff options
Diffstat (limited to 'client/HandleMessage.cpp')
| -rw-r--r-- | client/HandleMessage.cpp | 28 | 
1 files changed, 27 insertions, 1 deletions
diff --git a/client/HandleMessage.cpp b/client/HandleMessage.cpp index a6b9ce4..399abe8 100644 --- a/client/HandleMessage.cpp +++ b/client/HandleMessage.cpp @@ -18,7 +18,33 @@ void HandleMessage::ParseToSQL(QString input) {  	output.append(")"); -	queryInsertData.exec(output); +void HandleMessage::ParseToSQL(QString input) +{ +    QSqlQuery queryInsertData; +    QString output = "INSERT INTO `tblMain` (`temperature`, `humidity`, `pressure`) VALUES "; +    QStringList data; +    QStringList list = input.split("\n"); +    for (int i = 0; i < list.size(); ++i) { + +        output += "("; + +        data=list[i].split(","); + +        for (int j = 1; j < data.size(); ++j) { +            bool valid; +            output.append(QString::number(data[j].toInt(&valid, 16))); +            if (j <= data[j].size()) { +                output.append(","); +            } + +        } +        output.append(")"); + +        if (i+1 < list.size()){ +            output.append(","); +        } +    } +   queryInsertData.exec(output);  }  |