diff --git a/documentation/tdenginedocs-cn/connector/index.html b/documentation/tdenginedocs-cn/connector/index.html index d808e42dda..8b4e989e8a 100644 --- a/documentation/tdenginedocs-cn/connector/index.html +++ b/documentation/tdenginedocs-cn/connector/index.html @@ -125,35 +125,36 @@ public Connection getConn() throws Exception{
或者
pip install src/connector/python/linux/python3/
在已安装Windows 客户端的情况下, 将文件"C:\TDengine\driver\taos.dll" 拷贝到 "C:\windows\system32" 目录下, 然后进入Windwos cmd 命令行界面
+在已安装Windows TDengine 客户端的情况下, 将文件"C:\TDengine\driver\taos.dll" 拷贝到 "C:\windows\system32" 目录下, 然后进入Windwos cmd 命令行界面
cd C:\TDengine\connector\python\windows
pip install python2\
或者
cd C:\TDengine\connector\python\windows
pip install python3\
* 如果机器上没有pip命令,用户可将src/connector/python/windows/python3或src/connector/python/windows/python2下的taos文件夹拷贝到应用程序的目录使用。
-在使用TDengine的python接口时,需导入TDengine客户端模块:
-import taos
+import taos
conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos")
c1 = conn.cursor()
+* host 是TDengine 服务端所有IP, config 为客户端配置文件所在目录
import datetime
-# create a database
+# 创建数据库
c1.execute('create database db')
c1.execute('use db')
-# create a table
+# 建表
c1.execute('create table tb (ts timestamp, temperature int, humidity float)')
-# insert a record
+# 插入数据
start_time = datetime.datetime(2019, 11, 1)
affected_rows = c1.execute('insert into tb values (\'%s\', 0, 0.0)' %start_time)
-# insert multiple records in a batch
+# 批量插入数据
time_interval = datetime.timedelta(seconds=60)
sqlcmd = ['insert into tb values']
for irow in range(1,11):
@@ -164,15 +165,15 @@ affected_rows = c1.execute(' '.join(sqlcmd))
写入数据
c1.execute('select * from tb')
-# fetch all returned results
+# 拉取查询结果
data = c1.fetchall()
-# data is a list of returned rows with each row being a tuple
+# 返回的结果是一个列表,每一行构成列表的一个元素
numOfRows = c1.rowcount
numOfCols = c1.descriptions
for irow in range(numOfRows):
print("Row%d: ts=%s, temperature=%d, humidity=%f" %(irow, data[irow][0], data[irow][1],data[irow][2])
-# use the cursor as an iterator to retrieve all returned results
+# 直接使用cursor 循环拉取查询结果
c1.execute('select * from tb')
for data in c1:
print("ts=%s, temperature=%d, humidity=%f" %(data[0], data[1],data[2])
diff --git a/documentation/tdenginedocs-en/connector/index.html b/documentation/tdenginedocs-en/connector/index.html
index ba1cbcaf85..0f9e6b4717 100644
--- a/documentation/tdenginedocs-en/connector/index.html
+++ b/documentation/tdenginedocs-en/connector/index.html
@@ -126,29 +126,30 @@ public Connection getConn() throws Exception{
TDengine installed, TDengine-client installed if on Windows
python 2.7 or >= 3.4
pip installed
-Install TDengine Python client
+Installation
Linux
-Users can find python client packages in our source code directory src/connector/python. There are two directories corresponding two python versions. Please choose the correct package to install. Users can use pip command to install:
+Users can find python client packages in our source code directory src/connector/python. There are two directories corresponding to two python versions. Please choose the correct package to install. Users can use pip command to install:
pip install src/connector/python/linux/python2/
or
pip install src/connector/python/linux/python3/
Windows
-Assume you have installed the Windows client , copy the file "C:\TDengine\driver\taos.dll" to the folder "C:\windows\system32", and then enter the cmd command interface
+Assumed the Windows TDengine client has been installed , copy the file "C:\TDengine\driver\taos.dll" to the folder "C:\windows\system32", and then enter the cmd Windows command interface
cd C:\TDengine\connector\python\windows
pip install python2\
or
cd C:\TDengine\connector\python\windows
pip install python3\
* If pip command is not installed on the system, users can choose to install pip or just copy the taos directory in the python client directory to the application directory to use.
-Python client interfaces
-To use TDengine Python client, import TDengine module at first:
-import taos
+Usage
Examples
+import TDengine module at first:
+import taos
get the connection
conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos")
c1 = conn.cursor()
+* host is the IP of TDengine server, and config is the directory where exists the TDengine client configure file
insert records into the database
import datetime