-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathtest.lua
More file actions
59 lines (50 loc) · 1.14 KB
/
Copy pathtest.lua
File metadata and controls
59 lines (50 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require("struct")
local config = DBConfig:new()
config.device = "mysql"
config.ip = "192.168.1.77"
config.dbname = "jw_test"
config.user = "root"
config.pswd = "1111"
config.port = 3306
pool = DBThreadPool:new(config)
pool:create(1)
function select()
local sql = SqlCommand:new("select id, blo from t_blob")
local func = function(errno, err, result)
while(result:fetch())
do
print("tableid:" .. result:getInt32())
local pack = BasePacket:new()
if result:readBlob(pack) > 0 then
local st = test_blob:new()
st:read(pack)
print("id:".. st.id .. ", str:" .. st.str)
for i = 1, #st.vec, 1 do
print(st.vec[i])
end
end
end
end
sql:addToPool(pool, func)
end
function insert()
local sql = SqlCommand:new("insert into t_blob(id, blo) values(?, ?)")
sql:pushInt32(1)
local st = test_blob:new()
st.id = 1314
st.str = "hello c++20"
st.vec = {1314,520,666}
local pack = BasePacket:new()
st:write(pack)
sql:pushBlob(pack)
sql:addToPool(pool, function(errno, err,result)
select()
end)
end
select()
event_init()
timer = UTimer:new()
timer:start(function ()
pool:update()
end, 10, 10)
event_run()