Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
937974bf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
937974bf
编写于
9月 01, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
9月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3296 from robotspace/develop
Update query api for Lua connector.
上级
17102c8e
48229de3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
20 deletion
+10
-20
README.md
README.md
+1
-0
tests/examples/lua/lua_connector.c
tests/examples/lua/lua_connector.c
+7
-18
tests/examples/lua/test.lua
tests/examples/lua/test.lua
+2
-2
未找到文件。
README.md
浏览文件 @
937974bf
...
...
@@ -169,6 +169,7 @@ The TDengine community has also kindly built some of their own connectors! Follo
-
[
Rust Connector
](
https://github.com/taosdata/TDengine/tree/master/tests/examples/rust
)
-
[
.Net Core Connector
](
https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos
)
-
[
Lua Connector
](
https://github.com/taosdata/TDengine/tree/develop/tests/examples/lua
)
# How to run the test cases and how to add a new test case?
TDengine's test framework and all test cases are fully open source.
...
...
tests/examples/lua/lua_connector.c
浏览文件 @
937974bf
...
...
@@ -58,8 +58,10 @@ static int l_query(lua_State *L){
int
table_index
=
lua_gettop
(
L
);
// printf("receive command:%s\r\n",s);
if
(
taos_query
(
taos
,
s
)
!=
0
){
printf
(
"failed, reason:%s
\n
"
,
taos_errstr
(
taos
));
result
=
taos_query
(
taos
,
s
);
int32_t
code
=
taos_errno
(
result
);
if
(
code
!=
0
){
printf
(
"failed, reason:%s
\n
"
,
taos_errstr
(
result
));
lua_pushnumber
(
L
,
-
1
);
lua_setfield
(
L
,
table_index
,
"code"
);
lua_pushstring
(
L
,
taos_errstr
(
taos
));
...
...
@@ -69,24 +71,13 @@ static int l_query(lua_State *L){
}
else
{
//printf("success to query.\n");
result
=
taos_use_result
(
taos
);
if
(
result
==
NULL
)
{
printf
(
"failed to get result, reason:%s
\n
"
,
taos_errstr
(
taos
));
lua_pushnumber
(
L
,
-
2
);
lua_setfield
(
L
,
table_index
,
"code"
);
lua_pushstring
(
L
,
taos_errstr
(
taos
));
lua_setfield
(
L
,
table_index
,
"error"
);
return
1
;
}
TAOS_ROW
row
;
int
rows
=
0
;
int
num_fields
=
taos_field_count
(
taos
);
int
num_fields
=
taos_field_count
(
result
);
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
char
temp
[
256
];
int
affectRows
=
taos_affected_rows
(
taos
);
int
affectRows
=
taos_affected_rows
(
result
);
// printf(" affect rows:%d\r\n", affectRows);
lua_pushnumber
(
L
,
0
);
lua_setfield
(
L
,
table_index
,
"code"
);
...
...
@@ -155,15 +146,13 @@ static int l_query(lua_State *L){
}
void
stream_cb
(
void
*
param
,
TAOS_RES
*
result
,
TAOS_ROW
row
){
struct
cb_param
*
p
=
(
struct
cb_param
*
)
param
;
TAOS_FIELD
*
fields
=
taos_fetch_fields
(
result
);
int
numFields
=
taos_num_fields
(
result
);
printf
(
"
\n
numfields:%d
\n
"
,
numFields
);
printf
(
"
\n\r
-----------------------------------------------------------------------------------
\n
"
);
// printf("r:%d, L:%d\n",p->callback, p->state);
lua_State
*
L
=
p
->
state
;
lua_rawgeti
(
L
,
LUA_REGISTRYINDEX
,
p
->
callback
);
...
...
tests/examples/lua/test.lua
浏览文件 @
937974bf
...
...
@@ -15,7 +15,7 @@ else
conn
=
res
.
conn
end
local
res
=
driver
.
query
(
conn
,
"drop database demo"
)
local
res
=
driver
.
query
(
conn
,
"drop database
if exists
demo"
)
res
=
driver
.
query
(
conn
,
"create database demo"
)
if
res
.
code
~=
0
then
...
...
@@ -106,7 +106,7 @@ end
--From now on we begin continous query in an definite (infinite if you want) loop.
local
loop_index
=
0
while
loop_index
<
2
0
do
while
loop_index
<
1
0
do
local
t
=
os.time
()
*
1000
local
v
=
loop_index
res
=
driver
.
query
(
conn
,
string.format
(
"INSERT INTO therm1 VALUES (%d, %d)"
,
t
,
v
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录