Logic Machine Forum
SQL server on Wiser - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Hardware (https://forum.logicmachine.net/forumdisplay.php?fid=12)
+--- Thread: SQL server on Wiser (/showthread.php?tid=4457)



SQL server on Wiser - sx3 - 20.12.2022

Hello,

Would it be possible to host a light-weight SQL server on the LM instead of running 3rd party Hardware just for the DB?
1 Table with 2-3 fields/columns is all I need. It would make sorting values in sqript queries much easier than than LUA sccripting against KNX GA's I think.


RE: SQL server on Wiser - admin - 20.12.2022

LM has SQLite built-in. Docs/examples: https://openrb.com/docs/db.htm
Just be careful not to overflow the database with data.


RE: SQL server on Wiser - sx3 - 21.12.2022

Thanks, how can I create a new table and fields? Didn't find that in the docs.


RE: SQL server on Wiser - admin - 21.12.2022

Table can be created like this. You will need some clean-up procedure otherwise the database size will keep increasing until it hits a hard limit and some parts of the system won't function properly anymore. For other SQL commands check this: https://sqlite.org/lang.html
Code:
db:query([[
  CREATE TABLE IF NOT EXISTS my_config (
    key TEXT PRIMARY KEY,
    value TEXT
  )
]])