2019年12月24日 星期二

Node-RED: mySQL

Node-RED: mySQL


Write SQL and then shoot into mySQL widget. Only really, SELECT, INSERT, UPDATE, DELETE




Choose database



SQL statements in the Topic field



Paste HTML in the Template widget.
Use ng-repeat to populate data obtained from msg.payload.
<table style="width:100%">
  <tr>
    <th>Index</th> 
    <th>Sensor</th>
    <th>Temperature</th> 
    <th>Humidity</th>
  </tr>
  <tr ng-repeat="x in msg.payload | limitTo:20">
    <td>{{$index}}</td>
    <td align="center">{{msg.payload[$index].SensorName}}</td>
    <td align="center">{{msg.payload[$index].Temperature}}</td> 
    <td align="center">{{msg.payload[$index].Humidity}}</td>
  </tr>
</table>
Data received



SELECT * FROM sensor
DELETE FROM sensor WHERE Sensor_Id = 6
UPDATE sensor SET Temperature = 0 WHERE Sensor_Id = 7
INSERT INTO sensor (SensorName, Temperature, Humidity) VALUES (“Sensor2”, 10, 20)


沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...