This is an automated email from the ASF dual-hosted git repository.

hxd pushed a commit to branch rel/0.10
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 735841e86138660a8da2c36f380216525a834090
Author: xiangdong huang <[email protected]>
AuthorDate: Mon Jun 22 20:40:05 2020 +0800

    fix python client example that be inconsistent with Server's thrift 
Transport instance
---
 client-py/src/client_example.py | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/client-py/src/client_example.py b/client-py/src/client_example.py
old mode 100644
new mode 100755
index 3c8f65a..b20f372
--- a/client-py/src/client_example.py
+++ b/client-py/src/client_example.py
@@ -20,9 +20,14 @@ import sys
 import struct
 
 # If you generate IoTDB python library manually, add it to your python path
-sys.path.append("../target")
 
-from thrift.protocol import TBinaryProtocol
+#for example, if you run compile.sh, you can use the following code:
+# sys.path.append("../target")
+
+#if you use maven to compile the thrift api, just use the follwoing code:
+sys.path.append("../../service-rpc/target/generated-sources-python")
+
+from thrift.protocol import TBinaryProtocol, TCompactProtocol
 from thrift.transport import TSocket, TTransport
 
 from iotdb.rpc.TSIService import Client, TSCreateTimeseriesReq, 
TSInsertRecordReq, \
@@ -159,9 +164,11 @@ if __name__ == '__main__':
     transport = TSocket.TSocket(ip, port)
 
     # Buffering is critical. Raw sockets are very slow
-    transport = TTransport.TBufferedTransport(transport)
+    transport = TTransport.TFramedTransport(transport)
 
     # Wrap in a protocol
+    # use TCompactProtocol if the server enable thrift compression,
+    # otherwise use TBinaryProtocol
     protocol = TBinaryProtocol.TBinaryProtocol(transport)
 
     # Create a client to use the protocol encoder
@@ -278,8 +285,8 @@ if __name__ == '__main__':
     resp = client.insertTablet(TSInsertTabletReq(sessionId,deviceId,
                                                   measurements, values,
                                                   times, dataTypes, rowCnt))
-    status = resp.statusList
-    print(status[0].message)
+    status = resp.code
+    print(status)
 
     # execute deletion (or other statements)
     resp = client.executeStatement(TSExecuteStatementReq(sessionId, "DELETE 
FROM "

Reply via email to