This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read/write mysql database
#2
Install packages:
https://dl.openrb.com/pkg/zlib_1.2.7-1_mxs.ipk
https://dl.openrb.com/pkg/libmysqlclient...-1_mxs.ipk
https://dl.openrb.com/pkg/liblua-mysql_2.2.0-2_mxs.ipk

Docs:
http://keplerproject.github.io/luasql/do...anual.html

Short example, don't use db as a variable name or you will mess up LM internal database connection

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()
Reply


Messages In This Thread
Read/write mysql database - by gjniewenhuijse - 14.01.2016, 09:49
RE: Read/write mysql database - by admin - 14.01.2016, 10:03
RE: Read/write mysql database - by RSV4 - 20.03.2016, 10:33
RE: Read/write mysql database - by admin - 21.03.2016, 06:59
RE: Read/write mysql database - by RSV4 - 21.03.2016, 09:59
RE: Read/write mysql database - by admin - 11.10.2016, 10:24
RE: Read/write mysql database - by g2g2g2 - 02.11.2016, 13:40
RE: Read/write mysql database - by g2g2g2 - 08.11.2016, 08:23
RE: Read/write mysql database - by admin - 08.11.2016, 08:26
RE: Read/write mysql database - by RSV4 - 06.12.2016, 23:08
RE: Read/write mysql database - by admin - 07.12.2016, 07:12
RE: Read/write mysql database - by RSV4 - 07.12.2016, 08:45
RE: Read/write mysql database - by admin - 07.12.2016, 09:09
RE: Read/write mysql database - by RSV4 - 07.12.2016, 09:27
RE: Read/write mysql database - by RSV4 - 18.12.2016, 00:05
RE: Read/write mysql database - by RSV4 - 18.12.2016, 07:58
RE: Read/write mysql database - by RSV4 - 18.12.2016, 10:28
RE: Read/write mysql database - by RSV4 - 11.01.2017, 23:19
RE: Read/write mysql database - by admin - 12.01.2017, 09:48
RE: Read/write mysql database - by RSV4 - 12.01.2017, 18:50
RE: Read/write mysql database - by FatMax - 17.02.2017, 12:45
RE: Read/write mysql database - by yeuwoo - 14.03.2017, 03:16
RE: Read/write mysql database - by admin - 14.03.2017, 06:53
RE: Read/write mysql database - by Thomas - 14.03.2017, 14:34
RE: Read/write mysql database - by admin - 05.09.2017, 13:50
RE: Read/write mysql database - by admin - 07.09.2017, 14:47
RE: Read/write mysql database - by pentadom - 18.11.2019, 16:54
RE: Read/write mysql database - by Daniel - 19.11.2019, 08:28
RE: Read/write mysql database - by pentadom - 19.11.2019, 09:37
RE: Read/write mysql database - by admin - 19.11.2019, 09:49
RE: Read/write mysql database - by pentadom - 19.11.2019, 10:22
RE: Read/write mysql database - by admin - 19.11.2019, 12:06
RE: Read/write mysql database - by pentadom - 19.11.2019, 12:23
RE: Read/write mysql database - by admin - 19.11.2019, 14:07
RE: Read/write mysql database - by pentadom - 19.11.2019, 19:12
RE: Read/write mysql database - by admin - 20.11.2019, 07:47
RE: Read/write mysql database - by pentadom - 17.05.2020, 08:18
RE: Read/write mysql database - by pentadom - 17.05.2020, 14:57
RE: Read/write mysql database - by Daniel - 18.05.2020, 07:38
RE: Read/write mysql database - by pentadom - 18.05.2020, 07:55
RE: Read/write mysql database - by admin - 18.05.2020, 07:50
RE: Read/write mysql database - by admin - 18.05.2020, 07:58
RE: Read/write mysql database - by pentadom - 18.05.2020, 08:01
RE: Read/write mysql database - by Daniel - 18.05.2020, 08:06
RE: Read/write mysql database - by pentadom - 18.05.2020, 08:08
RE: Read/write mysql database - by pentadom - 19.05.2020, 16:08
RE: Read/write mysql database - by admin - 20.05.2020, 07:38
RE: Read/write mysql database - by pentadom - 20.05.2020, 16:27

Forum Jump: