luasql接続mysqlデータベース、データの遍歴

453 ワード


 require "luasql.mysql"

env = assert (luasql.mysql())
con = assert (env:connect("dbname","username","password","127.0.0.1",3306))
con:execute("SET NAMES gb2312")
local cur = con:execute("select * from test")
row = cur:fetch({},"a")
while  row do
    row = cur:fetch({},"a")
    if(row == nil) then break end
    print(row.id)

end
cur:close()
con:close()