TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

about python call taos.dll

Open schenton opened this issue 6 years ago • 2 comments

I want to subscribe data from taosdata's table. the way I found to achive this is to use the API function. so i try to use python to call taos.dll in windows system. but i encountered some problems. the code is below.

dll = cdll.LoadLibrary Objdll = windll.LoadLibrary("lib/taos.dll") #load the taos.dll pHost = bytes("192.168.25.160", "utf-8") pUser = bytes("root", "utf-8") pPassword = bytes("taosdata", "utf-8") pDatabase = bytes("seisflink", "utf-8") pTable = bytes("test_table", "utf-8") p_sub = c_void_p(Objdll.taos_subscribe(pHost, pUser, pPassword, pDatabase, pTable, c_int64(0), c_int(10000))) #subscribe the data count = c_int(Objdll.taos_subfields_count(byref(p_sub))) #the count is 0, maybe some problem? while True: row = Objdll.taos_consume(byref(p_sub)); #how can i parse the struct of row? pass

question:

  1. is another way to achive the goal(subscribe the data) using python?
  2. is any demo about to call taos.dll using python?
  3. how can i parse the struct "row"? i check the taos.h, the struct "row" defined as "typedef void** TAOS_ROW;" so, i don't know the detail about the struct 'row', and i can't built a struct in python to reflect the struct "row" which is returnd in the function of taos_consume()

schenton avatar Dec 25 '19 05:12 schenton

  1. we provide a demo code to subscribe the data, but it is C driver https://github.com/taosdata/TDengine/blob/develop/tests/examples/c/subscribe.c
  2. as for how to call taos.dll using python, you can refer to https://github.com/taosdata/TDengine/blob/develop/src/connector/python/windows/python3/taos/cinterface.py and other python file in the 'taos' folder.

fangpanpan avatar Dec 25 '19 07:12 fangpanpan

thanks a lot for saving me from reprogramming in C

schenton avatar Dec 26 '19 07:12 schenton