mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
mysql lib
This commit is contained in:
32
test/testmysql.lua
Normal file
32
test/testmysql.lua
Normal file
@@ -0,0 +1,32 @@
|
||||
local skynet = require "skynet"
|
||||
local mysql = require "mysql"
|
||||
|
||||
skynet.start(function()
|
||||
|
||||
local db=mysql.connect{
|
||||
host="192.168.1.218",
|
||||
port=3306,
|
||||
database="Battle_Data",
|
||||
user="root",
|
||||
password="1"
|
||||
}
|
||||
if not db then
|
||||
print("failed to connect")
|
||||
end
|
||||
print("testmysql success to connect to mysql server")
|
||||
|
||||
--local res=db:query("select * from test1;select * from test1")
|
||||
local res=db:query("select * from G_BuildData_0 limit 10")
|
||||
print(res)
|
||||
for k,v in pairs(res) do
|
||||
print("k=",k,"v=",v)
|
||||
if type(v)=="table" then
|
||||
for kk, vv in pairs(v) do
|
||||
print("kk=",kk,"vv=",v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
skynet.exit()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user