Logic Machine Forum
Mysql query - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Mysql query (/showthread.php?tid=5015)



Mysql query - toujour - 11.10.2023

Hi,

  where can I find an "how to" for mysql integration ?

For example:
I want insert/read some values in a remote database (in the same LAN).

If there is an example it'll be appreciate.

BR,
Alberto


RE: Mysql query - Daniel - 11.10.2023

Look here, make sure you install correct packages as this thread is very old
https://forum.logicmachine.net/showthread.php?tid=193&pid=797#pid797


RE: Mysql query - toujour - 17.10.2023

thanks for your reply but I don't find the correct link in that thread...all the links are offline (404).
Can you check it, please ?


RE: Mysql query - Daniel - 17.10.2023

Extra packages are always below the firmware links
https://dl.openrb.com/lm-23-imx6/pkg/


RE: Mysql query - toujour - 18.10.2023

ok....and the docs about it, please ?


RE: Mysql query - admin - 18.10.2023

https://forum.logicmachine.net/showthread.php?tid=193


RE: Mysql query - toujour - 18.10.2023

ok, this for request (it works with luamysql package).

Code:
require('luasql.mysql')

env = luasql.mysql()
dbcon = env:connect(DB_NAME, USERNAME, PASSWORD, MYSQL_SERVER_IP, MYSQL_SERVER_PORT)
cursor = dbcon:execute('SELECT * FROM mytable')

while true do
  row = cursor:fetch({}, 'a')

  if row then
    log(row)
  else
    break
  end
end

cursor:close()
dbcon:close()
env:close()