aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/dbconnector.cpp11
-rw-r--r--client/dbconnector.h4
-rw-r--r--client/dbconnector.ui5
-rw-r--r--client/main.cpp9
-rw-r--r--client/mainwindow.cpp104
-rw-r--r--client/mainwindow.h20
-rw-r--r--client/mainwindow.ui63
-rw-r--r--client/ui_dbconnector.h3
-rw-r--r--client/ui_mainwindow.h59
-rw-r--r--scripts/db-add.sql194
-rw-r--r--scripts/db-init.sql20
-rw-r--r--scripts/db-privileges.sql1
12 files changed, 347 insertions, 146 deletions
diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp
index 5ed1efc..186f8f7 100644
--- a/client/dbconnector.cpp
+++ b/client/dbconnector.cpp
@@ -2,7 +2,7 @@
#include "ui_dbconnector.h"
#include "main.h"
-//#include "mainwindow.h"
+#include "mainwindow.h"
dbConnector::dbConnector(QWidget *parent) :
QDialog(parent),
@@ -26,19 +26,16 @@ void dbConnector::on_pushButton_login_clicked()
QString hostname = ui->lineEdit_adress->text();
QString username = ui->lineEdit_username->text();
QString password = ui->lineEdit_password->text();
- QString databaseName = "thecrapbox";
+ QString databaseName = ui->lineEdit_database->text();
-// QSqlDatabase db = MainWindow.loginDb(adress, username, password);
-
-// QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
-// return;
dbRef.setHostName(hostname);
dbRef.setUserName(username);
dbRef.setPassword(password);
- dbRef.setDatabaseName("thecrapbox");
+ dbRef.setDatabaseName(databaseName);
if(dbRef.open()){
QMessageBox::information(this, "Connection", "GREAT SUCCES!");
+ dbConnector::~dbConnector();
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
diff --git a/client/dbconnector.h b/client/dbconnector.h
index cd722eb..db8ac4e 100644
--- a/client/dbconnector.h
+++ b/client/dbconnector.h
@@ -6,7 +6,6 @@
//#include <QtSql>
//#include <QSqlDatabase>
-//#include "database.h"
namespace Ui {
class dbConnector;
@@ -21,7 +20,6 @@ public:
~dbConnector();
private slots:
-// void on_pushButton_clicked();
void on_pushButton_cancel_clicked();
@@ -29,6 +27,4 @@ private slots:
private:
Ui::dbConnector *ui;
-
-// Database database;
};
diff --git a/client/dbconnector.ui b/client/dbconnector.ui
index 21d241f..1159faf 100644
--- a/client/dbconnector.ui
+++ b/client/dbconnector.ui
@@ -49,6 +49,9 @@
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_database">
+ <property name="text">
+ <string>WSdb</string>
+ </property>
<property name="placeholderText">
<string>Database name</string>
</property>
@@ -98,7 +101,7 @@
</font>
</property>
<property name="text">
- <string/>
+ <string>Ab12345!</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
diff --git a/client/main.cpp b/client/main.cpp
index 0f6b816..8561786 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -9,8 +9,8 @@
#include <iostream>
#include <stdio.h>
-#include "chart.h"
-#include "chartview.h"
+//#include "chart.h"
+//#include "chartview.h"
#include "mainwindow.h"
#include "main.h"
#include "ui_mainwindow.h"
@@ -25,8 +25,9 @@ int main(int argc, char *argv[])
TimeTest time;
MyTcpSocket s;
// s.doConnect();
- MainWindow w;
- dbRef = QSqlDatabase::addDatabase("QMYSQL");
+ MainWindow w;
+
+ dbRef = QSqlDatabase::addDatabase("QMYSQL");
w.show();
return a.exec();
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index 955307e..e1736e6 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -4,11 +4,12 @@
#include "ui_mainwindow.h"
#include "main.h"
+#include <QDebug>
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
-// db = QSqlDatabase::addDatabase("QMYSQL");
ui->setupUi(this);
}
@@ -18,33 +19,98 @@ MainWindow::~MainWindow()
delete ui;
}
-void MainWindow::on_actionAbout_triggered()
+void MainWindow::on_actionConnection_triggered()
{
- QMessageBox::warning(this, "Oops..", "Task Failed succesfully ;)");
+ _dbConenctor = new dbConnector(this);
+ _dbConenctor->show();
}
+void MainWindow::on_actionRefresh_triggered()
+{
+ drawGraph();
+}
-void MainWindow::on_pushButton_clicked()
+void MainWindow::on_actionDisconnenct_triggered()
{
-// dbRef = QSqlDatabase::addDatabase("QMYSQL");
-// dbRef.setHostName("localhost");
-// dbRef.setUserName("root");
-// dbRef.setPassword("Ab12345!");
-// dbRef.setDatabaseName("thecrapbox");
+ dbRef.close();
+}
+
+
+void MainWindow::drawGraph(){
+ QLineSeries *seriesTemperature = new QLineSeries();
+ QLineSeries *seriesHumidity = new QLineSeries();
+ QLineSeries *seriesPressure = new QLineSeries();
+
+
if(dbRef.open()){
- QMessageBox::information(this, "Connection", "GREAT SUCCES!");
- pQueryModel = new QSqlQueryModel();
- pQueryModel->setQuery("SELECT * FROM opleiding;");
- ui->tableView->setModel(pQueryModel);
+ QSqlQuery queryGraphData;
+// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;");
+ queryGraphData.exec("select * FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 190;");
+
+ for (int i = 0; queryGraphData.next(); ++i) {
+// int time = queryGraphData.value(4).toTime().hour()*100 + queryGraphData.value(4).toTime().minute();
+ int time = i;
+// seriesPressure->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toFloat());
+// seriesTemperature->append(i, queryGraphData.value(1).toInt());
+// seriesHumidity->append(i, queryGraphData.value(2).toFloat());
+// seriesPressure->append(i, queryGraphData.value(3).toInt());
+
+ seriesTemperature->append(time, queryGraphData.value(1).toFloat());
+ seriesHumidity->append(time, queryGraphData.value(2).toFloat());
+ seriesPressure->append(time, (queryGraphData.value(3).toFloat()*100));
+
+// qDebug() << time;
+ }
+
+// QPen pen(QRgb(0x57FF00));
+// pen.setWidth(5);
+// seriesHumidity->setPen(pen);
+
+
+ QChart *chartTemperature = new QChart();
+ chartTemperature->legend()->hide();
+ chartTemperature->addSeries(seriesTemperature);
+ chartTemperature->createDefaultAxes();
+ chartTemperature->setTitle("Temperature!");
+ QChartView *chartView1 = new QChartView(chartTemperature);
+
+ QChart *chartHumidity = new QChart();
+ chartHumidity->legend()->hide();
+ chartHumidity->addSeries(seriesHumidity);
+ chartHumidity->createDefaultAxes();
+ chartHumidity->setTitle("Humidity!");
+ QChartView *chartView2 = new QChartView(chartHumidity);
+
+ QChart *chartPressure = new QChart();
+ chartPressure->legend()->hide();
+ chartPressure->addSeries(seriesPressure);
+ chartPressure->createDefaultAxes();
+ chartPressure->setTitle("Pressure!");
+ QChartView *chartView3 = new QChartView(chartPressure);
+
+
+ QWidget *window = new QWidget;
+ QGridLayout *layout = new QGridLayout(window);
+ layout->addWidget(chartView1, 0 ,0);
+ layout->addWidget(chartView2, 1 ,0);
+ layout->addWidget(chartView3, 2 ,0);
+
+ layout->setVerticalSpacing(0);
+ layout->setHorizontalSpacing(0);
+ layout->setContentsMargins(0,0,0,0);
+
+
+
+// window->show();
+
+ MainWindow::setCentralWidget(window);
+
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
-}
-
-void MainWindow::on_actionConnection_triggered()
-{
- _dbConenctor = new dbConnector(this);
- _dbConenctor->show();
+// delete seriesTemperature;
+// delete seriesHumidity;
+// delete seriesPressure;
}
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 1e73657..25e22ec 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -8,6 +8,10 @@
#include <QMessageBox>
#include <QtSql>
#include <QSqlDatabase>
+#include <QtCharts>
+#include <QWidget>
+#include <QWidgetSet>
+
#include "main.h"
@@ -23,20 +27,26 @@ public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
+ virtual void drawGraph();
+
private slots:
- void on_actionAbout_triggered();
+// void on_actionAbout_triggered();
- void on_pushButton_clicked();
+// void on_pushButton_clicked();
void on_actionConnection_triggered();
+ void on_actionRefresh_triggered();
+
+ void on_actionDisconnenct_triggered();
+
private:
Ui::MainWindow *ui;
dbConnector *_dbConenctor;
-// QSqlDatabase db;
- QSqlQueryModel *pQueryModel;
+ QChart *_pChart;
+// QLineSeries *_pSeries;
+ QChartView *_pChartView;
-// Database database;
};
diff --git a/client/mainwindow.ui b/client/mainwindow.ui
index f827c85..a31ffdc 100644
--- a/client/mainwindow.ui
+++ b/client/mainwindow.ui
@@ -14,36 +14,18 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
- <widget class="QPushButton" name="pushButton">
- <property name="enabled">
- <bool>true</bool>
- </property>
+ <widget class="QLabel" name="label">
<property name="geometry">
<rect>
- <x>310</x>
- <y>0</y>
- <width>121</width>
- <height>41</height>
+ <x>270</x>
+ <y>190</y>
+ <width>181</width>
+ <height>51</height>
</rect>
</property>
<property name="text">
- <string>DoesSomething</string>
- </property>
- </widget>
- <widget class="QWidget" name="verticalLayoutWidget">
- <property name="geometry">
- <rect>
- <x>-10</x>
- <y>40</y>
- <width>801</width>
- <height>401</height>
- </rect>
+ <string>Please load data first</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QTableView" name="tableView"/>
- </item>
- </layout>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
@@ -52,45 +34,33 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>21</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuAbouy">
<property name="title">
<string>Home</string>
</property>
- <addaction name="actionAbout"/>
<addaction name="actionRefresh"/>
</widget>
- <widget class="QMenu" name="menuTEMP">
- <property name="title">
- <string>TEMP</string>
- </property>
- <addaction name="actionLOAD"/>
- <addaction name="actionQuerry"/>
- </widget>
<widget class="QMenu" name="menuDatabase">
<property name="title">
<string>Database</string>
</property>
<addaction name="actionConnection"/>
<addaction name="actionDisconnenct"/>
- <addaction name="actionStatus"/>
</widget>
<addaction name="menuAbouy"/>
- <addaction name="menuTEMP"/>
<addaction name="menuDatabase"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
- <action name="actionAbout">
- <property name="text">
- <string>About</string>
- </property>
- </action>
<action name="actionRefresh">
<property name="text">
<string>Refresh</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+R</string>
+ </property>
</action>
<action name="actionLOAD">
<property name="text">
@@ -106,22 +76,15 @@
<property name="text">
<string>Connect</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
</action>
<action name="actionDisconnenct">
<property name="text">
<string>Disconnenct</string>
</property>
</action>
- <action name="actionQuerry_2">
- <property name="text">
- <string>Querry</string>
- </property>
- </action>
- <action name="actionStatus">
- <property name="text">
- <string>Status</string>
- </property>
- </action>
</widget>
<resources/>
<connections/>
diff --git a/client/ui_dbconnector.h b/client/ui_dbconnector.h
index afb6f11..dec4d7b 100644
--- a/client/ui_dbconnector.h
+++ b/client/ui_dbconnector.h
@@ -139,12 +139,13 @@ public:
lineEdit_adress->setText(QCoreApplication::translate("dbConnector", "localhost", nullptr));
lineEdit_adress->setPlaceholderText(QCoreApplication::translate("dbConnector", "Hostname/IP-Adress", nullptr));
label_4->setText(QCoreApplication::translate("dbConnector", "Database", nullptr));
+ lineEdit_database->setText(QCoreApplication::translate("dbConnector", "WSdb", nullptr));
lineEdit_database->setPlaceholderText(QCoreApplication::translate("dbConnector", "Database name", nullptr));
label->setText(QCoreApplication::translate("dbConnector", "Username", nullptr));
lineEdit_username->setText(QCoreApplication::translate("dbConnector", "root", nullptr));
lineEdit_username->setPlaceholderText(QCoreApplication::translate("dbConnector", "Username", nullptr));
label_2->setText(QCoreApplication::translate("dbConnector", "Password", nullptr));
- lineEdit_password->setText(QString());
+ lineEdit_password->setText(QCoreApplication::translate("dbConnector", "Ab12345!", nullptr));
lineEdit_password->setPlaceholderText(QCoreApplication::translate("dbConnector", "Password", nullptr));
connectLabel->setText(QCoreApplication::translate("dbConnector", "Connect", nullptr));
pushButton_login->setText(QCoreApplication::translate("dbConnector", "Login", nullptr));
diff --git a/client/ui_mainwindow.h b/client/ui_mainwindow.h
index 8854685..46bb29a 100644
--- a/client/ui_mainwindow.h
+++ b/client/ui_mainwindow.h
@@ -12,14 +12,11 @@
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
-#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QLabel>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QPushButton>
#include <QtWidgets/QStatusBar>
-#include <QtWidgets/QTableView>
-#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
@@ -27,22 +24,15 @@ QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
- QAction *actionAbout;
QAction *actionRefresh;
QAction *actionLOAD;
QAction *actionQuerry;
QAction *actionConnection;
QAction *actionDisconnenct;
- QAction *actionQuerry_2;
- QAction *actionStatus;
QWidget *centralwidget;
- QPushButton *pushButton;
- QWidget *verticalLayoutWidget;
- QVBoxLayout *verticalLayout;
- QTableView *tableView;
+ QLabel *label;
QMenuBar *menubar;
QMenu *menuAbouy;
- QMenu *menuTEMP;
QMenu *menuDatabase;
QStatusBar *statusbar;
@@ -51,8 +41,6 @@ public:
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(800, 600);
- actionAbout = new QAction(MainWindow);
- actionAbout->setObjectName(QString::fromUtf8("actionAbout"));
actionRefresh = new QAction(MainWindow);
actionRefresh->setObjectName(QString::fromUtf8("actionRefresh"));
actionLOAD = new QAction(MainWindow);
@@ -63,35 +51,17 @@ public:
actionConnection->setObjectName(QString::fromUtf8("actionConnection"));
actionDisconnenct = new QAction(MainWindow);
actionDisconnenct->setObjectName(QString::fromUtf8("actionDisconnenct"));
- actionQuerry_2 = new QAction(MainWindow);
- actionQuerry_2->setObjectName(QString::fromUtf8("actionQuerry_2"));
- actionStatus = new QAction(MainWindow);
- actionStatus->setObjectName(QString::fromUtf8("actionStatus"));
centralwidget = new QWidget(MainWindow);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
- pushButton = new QPushButton(centralwidget);
- pushButton->setObjectName(QString::fromUtf8("pushButton"));
- pushButton->setEnabled(true);
- pushButton->setGeometry(QRect(310, 0, 121, 41));
- verticalLayoutWidget = new QWidget(centralwidget);
- verticalLayoutWidget->setObjectName(QString::fromUtf8("verticalLayoutWidget"));
- verticalLayoutWidget->setGeometry(QRect(-10, 40, 801, 401));
- verticalLayout = new QVBoxLayout(verticalLayoutWidget);
- verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
- verticalLayout->setContentsMargins(0, 0, 0, 0);
- tableView = new QTableView(verticalLayoutWidget);
- tableView->setObjectName(QString::fromUtf8("tableView"));
-
- verticalLayout->addWidget(tableView);
-
+ label = new QLabel(centralwidget);
+ label->setObjectName(QString::fromUtf8("label"));
+ label->setGeometry(QRect(270, 190, 181, 51));
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
menubar->setObjectName(QString::fromUtf8("menubar"));
- menubar->setGeometry(QRect(0, 0, 800, 21));
+ menubar->setGeometry(QRect(0, 0, 800, 24));
menuAbouy = new QMenu(menubar);
menuAbouy->setObjectName(QString::fromUtf8("menuAbouy"));
- menuTEMP = new QMenu(menubar);
- menuTEMP->setObjectName(QString::fromUtf8("menuTEMP"));
menuDatabase = new QMenu(menubar);
menuDatabase->setObjectName(QString::fromUtf8("menuDatabase"));
MainWindow->setMenuBar(menubar);
@@ -100,15 +70,10 @@ public:
MainWindow->setStatusBar(statusbar);
menubar->addAction(menuAbouy->menuAction());
- menubar->addAction(menuTEMP->menuAction());
menubar->addAction(menuDatabase->menuAction());
- menuAbouy->addAction(actionAbout);
menuAbouy->addAction(actionRefresh);
- menuTEMP->addAction(actionLOAD);
- menuTEMP->addAction(actionQuerry);
menuDatabase->addAction(actionConnection);
menuDatabase->addAction(actionDisconnenct);
- menuDatabase->addAction(actionStatus);
retranslateUi(MainWindow);
@@ -118,17 +83,19 @@ public:
void retranslateUi(QMainWindow *MainWindow)
{
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
- actionAbout->setText(QCoreApplication::translate("MainWindow", "About", nullptr));
actionRefresh->setText(QCoreApplication::translate("MainWindow", "Refresh", nullptr));
+#if QT_CONFIG(shortcut)
+ actionRefresh->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+R", nullptr));
+#endif // QT_CONFIG(shortcut)
actionLOAD->setText(QCoreApplication::translate("MainWindow", "Load", nullptr));
actionQuerry->setText(QCoreApplication::translate("MainWindow", "Query", nullptr));
actionConnection->setText(QCoreApplication::translate("MainWindow", "Connect", nullptr));
+#if QT_CONFIG(shortcut)
+ actionConnection->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+O", nullptr));
+#endif // QT_CONFIG(shortcut)
actionDisconnenct->setText(QCoreApplication::translate("MainWindow", "Disconnenct", nullptr));
- actionQuerry_2->setText(QCoreApplication::translate("MainWindow", "Querry", nullptr));
- actionStatus->setText(QCoreApplication::translate("MainWindow", "Status", nullptr));
- pushButton->setText(QCoreApplication::translate("MainWindow", "DoesSomething", nullptr));
+ label->setText(QCoreApplication::translate("MainWindow", "Please load data first", nullptr));
menuAbouy->setTitle(QCoreApplication::translate("MainWindow", "Home", nullptr));
- menuTEMP->setTitle(QCoreApplication::translate("MainWindow", "TEMP", nullptr));
menuDatabase->setTitle(QCoreApplication::translate("MainWindow", "Database", nullptr));
} // retranslateUi
diff --git a/scripts/db-add.sql b/scripts/db-add.sql
new file mode 100644
index 0000000..6b202aa
--- /dev/null
+++ b/scripts/db-add.sql
@@ -0,0 +1,194 @@
+INSERT INTO `WSdb`.`tblMain` (temperature, humidity) VALUES
+-- 20.6, 77.7, 0.59, now()
+(23.6,57),
+(23.6,57),
+(23.6,56),
+(23.6,56),
+(23.5,58),
+(23.4,59),
+(23.4,59),
+(23.4,60),
+(23.4,60),
+(23.4,60),
+(23.3,60),
+(23.3,60),
+(23.3,60),
+(23.2,60),
+(23.4,60),
+(23.3,60),
+(23.2,60),
+(23.2,59),
+(23.1,59),
+(23.1,59),
+(23.0,59),
+(23.0,59),
+(22.9,59),
+(22.9,59),
+(22.9,58),
+(22.8,58),
+(22.8,58),
+(22.8,58),
+(22.8,58),
+(22.7,58),
+(22.7,58),
+(22.7,58),
+(22.6,58),
+(22.6,58),
+(22.6,58),
+(22.6,58),
+(22.5,58),
+(22.5,58),
+(22.5,58),
+(22.4,58),
+(22.4,58),
+(22.4,58),
+(22.4,57),
+(22.4,57),
+(22.3,57),
+(22.3,57),
+(22.3,57),
+(22.3,57),
+(22.3,57),
+(22.4,57),
+(22.7,57),
+(22.9,57),
+(23.0,57),
+(23.2,57),
+(23.2,57),
+(23.1,59),
+(23.0,59),
+(23.0,59),
+(23.2,58),
+(23.4,58),
+(23.4,58),
+(23.5,57),
+(23.6,57),
+(23.7,57),
+(23.7,57),
+(23.8,57),
+(23.9,57),
+(23.8,59),
+(23.8,59),
+(23.7,58),
+(23.6,58),
+(23.5,58),
+(23.5,58),
+(23.4,57),
+(23.5,59),
+(23.8,58),
+(23.7,59),
+(23.7,59),
+(23.7,59),
+(23.9,59),
+(23.8,57),
+(23.7,56),
+(23.5,55),
+(23.4,54),
+(23.4,54),
+(23.6,53),
+(23.6,56),
+(23.7,55),
+(23.7,54),
+(23.8,54),
+(23.8,54),
+(23.8,55),
+(23.7,55),
+(23.6,55),
+(23.5,55),
+(23.5,56),
+(23.4,56),
+(23.4,58),
+(23.3,59),
+(23.4,63),
+(23.4,63),
+(23.4,63),
+(23.4,63),
+(23.4,63),
+(23.3,64),
+(23.2,63),
+(23.2,62),
+(23.1,62),
+(23.1,61),
+(23.0,61),
+(22.9,61),
+(22.9,61),
+(22.9,61),
+(22.8,60),
+(22.8,60),
+(22.8,60),
+(22.7,60),
+(22.7,60),
+(22.6,60),
+(22.6,60),
+(22.5,59),
+(22.5,59),
+(22.5,59),
+(22.4,59),
+(22.4,59),
+(22.4,59),
+(22.4,59),
+(22.4,59),
+(22.4,58),
+(22.3,58),
+(22.3,58),
+(22.3,58),
+(22.3,58),
+(22.2,58),
+(22.2,58),
+(22.2,58),
+(22.2,58),
+(22.2,58),
+(22.1,58),
+(22.1,58),
+(22.1,58),
+(22.1,57),
+(22.0,57),
+(22.0,57),
+(22.0,57),
+(22.1,58),
+(22.4,57),
+(22.5,58),
+(22.6,58),
+(22.7,58),
+(22.8,58),
+(22.9,58),
+(22.9,58),
+(22.8,57),
+(22.7,57),
+(22.7,57),
+(22.9,57),
+(22.9,57),
+(23.0,58),
+(23.2,58),
+(23.3,58),
+(23.2,59),
+(23.2,59),
+(23.2,58),
+(23.4,58),
+(23.6,59),
+(23.7,59),
+(23.9,59),
+(24.0,58),
+(23.9,55),
+(23.9,54),
+(23.9,55),
+(24.0,55),
+(24.2,55),
+(24.2,55),
+(24.1,56),
+(24.0,55),
+(24.0,56),
+(23.9,57),
+(23.9,56),
+(24.0,55),
+(24.1,55),
+(23.9,56),
+(23.9,56),
+(23.9,56),
+(23.9,56),
+(23.8,56),
+(23.8,56),
+(23.7,56),
+(23.7,56),
+(23.6,58),
+(23.6,59);
diff --git a/scripts/db-init.sql b/scripts/db-init.sql
index 4c4c4d4..2b0581c 100644
--- a/scripts/db-init.sql
+++ b/scripts/db-init.sql
@@ -1,9 +1,11 @@
-CREATE SCHEMA `WSdb`;
-CREATE TABLE `DAB1Pract1`.`tblMain` (
- `ID` INT GENERATED ALWAYS AS (),
- `temperature` DECIMAL(5,2) NULL,
- `humidity` DECIMAL(5,2) NULL,
- `pressure` DECIMAL(5,2) NULL,
- `time` DATETIME NULL,
- PRIMARY KEY (`ID`),
- UNIQUE INDEX `ID_UNIQUE` (`ID` ASC) VISIBLE);
+drop schema if exists `WSdb`;
+create schema if not exists `WSdb`;
+drop table if exists `WSdb`.`tblMain`;
+create table if not exists `WSdb`.`tblMain` (
+ id int unsigned not null auto_increment,
+ temperature decimal(5,2) null,
+ humidity decimal(5,2) null,
+ pressure decimal(5,2) null,
+ time datetime null,
+ primary key (id)
+);
diff --git a/scripts/db-privileges.sql b/scripts/db-privileges.sql
new file mode 100644
index 0000000..75f8fcc
--- /dev/null
+++ b/scripts/db-privileges.sql
@@ -0,0 +1 @@
+grant all privileges on WSdb.* to 'user'@'localhost';