【发布时间】:2021-04-05 03:28:41
【问题描述】:
我想从 NodeRed mysql 节点中退出。我想向 MySQL 发送一个查询并接收一个输出,该输出给出了我的数据库的大小。数据库名称为 demoopcua。
这是连接的图像:
这是我的功能:
msg.topic = "SELECT table_schema AS demoopcua,ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS `Size (MB)`,FROM information_schema.TABLES GROUP BY table_schema;"
如果你想导入它,这里是流程:
[{"id":"a98232e2.89bb4","type":"tab","label":"Data Storage ","disabled":false,"info":""},{"id":"f50611a.320baf","type":"mysql","z":"a98232e2.89bb4","mydb":"f1e0508e.13503","name":"db","x":470,"y":360,"wires":[["73e15eff.866b3"]]},{"id":"73e15eff.866b3","type":"debug","z":"a98232e2.89bb4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":360,"wires":[]},{"id":"6936d2d6.33b00c","type":"function","z":"a98232e2.89bb4","name":"","func":"msg.topic = \"SELECT table_schema AS demoopcua,ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS `Size (MB)`,FROM information_schema.TABLES GROUP BY table_schema;\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":360,"wires":[["f50611a.320baf"]]},{"id":"ee29a71.86c0b58","type":"inject","z":"a98232e2.89bb4","name":"","props":[{"p":"payload"},{"p":"topic","v":"","vt":"msg"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":360,"wires":[["6936d2d6.33b00c"]]},{"id":"f1e0508e.13503","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"test dump","tz":"","charset":"UTF8"}]
【问题讨论】:
-
如果没有数据库架构,我们将无能为力。此外,这很可能是 SQL 问题而不是 Node-RED 问题,假设您在提交该查询时没有收到任何错误。
-
我不太清楚你所说的数据库模式是什么意思。此外,当我运行此流程时,我确实收到了错误消息。我明白了:
"Error: Invalid property expression: zero-length" -
检查 SQL 查询中的单引号,它们可能应该是 ' 而不是 `
-
我仍然得到同样的零长度错误:(。我为任何误解道歉。我对此很陌生,我仍在学习。
标签: mysql sql database node-red