在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
==========================example for lua json======================= local cjson = require("cjson") local str = '["a", "b", "c"]' local j = cjson.decode(str) for i,v in ipairs(j) do print(v) end str = '{"A":1, "B":2}' j = cjson.decode(str) for k,v in pairs(j) do print(k..":"..v) end j['C']='c' new_str = cjson.encode(j) print(new_str) ==========================example for lua mysql======================= mysql.lua require "luasql.mysql" env = assert(luasql.mysql()) conn = assert(env:connect("fsdb","root","123456","127.0.0.1",3306)) conn:execute"SET NAMES utf8" function rows (connection, sql_statement) local cursor = assert (connection:execute (sql_statement)) return function () return cursor:fetch() end end for did, status in rows(conn ,"SELECT driverid,status from fs_driver_products") do print(string.format("%s %s",name,email)) end conn:close() env:close() lua操作mysql的库文件 http://luaforge.net/projects/luasql/ lua操作redis的库文件 需要依赖luasocket库文件。 Lua加载lua文件时,需要设置 package.path |
请发表评论