diff --git a/CMakeLists.txt b/CMakeLists.txt index dcad242a303f4546e93e1e86e94c9d613c3b0de8..9c446b19a548e2f2f84d147d59327bee66d56caa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,21 +38,56 @@ IF (NOT DEFINED TD_CLUSTER) # Set macro definitions according to os platform SET(TD_LINUX_64 FALSE) SET(TD_LINUX_32 FALSE) + SET(TD_ARM FALSE) SET(TD_ARM_64 FALSE) SET(TD_ARM_32 FALSE) SET(TD_MIPS_64 FALSE) SET(TD_DARWIN_64 FALSE) SET(TD_WINDOWS_64 FALSE) + # if generate ARM version: + # cmake -DARMVER=arm32 .. or cmake -DARMVER=arm64 + IF (${ARMVER} MATCHES "arm32") + SET(TD_ARM TRUE) + SET(TD_ARM_32 TRUE) + ADD_DEFINITIONS(-D_TD_ARM_) + ADD_DEFINITIONS(-D_TD_ARM_32_) + ELSEIF (${ARMVER} MATCHES "arm64") + SET(TD_ARM TRUE) + SET(TD_ARM_64 TRUE) + ADD_DEFINITIONS(-D_TD_ARM_) + ADD_DEFINITIONS(-D_TD_ARM_64_) + ENDIF () + + IF (TD_ARM) + ADD_DEFINITIONS(-D_TD_ARM_) + IF (TD_ARM_32) + ADD_DEFINITIONS(-D_TD_ARM_32_) + ELSEIF (TD_ARM_64) + ADD_DEFINITIONS(-D_TD_ARM_64_) + ELSE () + EXIT () + ENDIF () + ENDIF () + IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) SET(TD_LINUX_64 TRUE) SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) ADD_DEFINITIONS(-D_M_X64) MESSAGE(STATUS "The current platform is Linux 64-bit") - ELSE () + ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4) + IF (TD_ARM) SET(TD_LINUX_32 TRUE) - MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, not supported yet") + SET(TD_OS_DIR ${TD_COMMUNITY_DIR}/src/os/linux) + #ADD_DEFINITIONS(-D_M_IX86) + MESSAGE(STATUS "The current platform is Linux 32-bit") + ELSE () + MESSAGE(FATAL_ERROR "The current platform is Linux 32-bit, but no ARM not supported yet") + EXIT () + ENDIF () + ELSE () + MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet") EXIT () ENDIF () ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -90,7 +125,9 @@ IF (NOT DEFINED TD_CLUSTER) # debug flag # # ADD_DEFINITIONS(-D_CHECK_HEADER_FILE_) - # ADD_DEFINITIONS(-D_TAOS_MEM_TEST_) + IF (${MEM_CHECK} MATCHES "true") + ADD_DEFINITIONS(-DTAOS_MEM_CHECK) + ENDIF () IF (TD_CLUSTER) ADD_DEFINITIONS(-DCLUSTER) @@ -102,13 +139,27 @@ IF (NOT DEFINED TD_CLUSTER) IF (TD_LINUX_64) SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(RELEASE_FLAGS "-O0") - IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + IF (NOT TD_ARM) + IF (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") + SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + ELSE () + SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + ENDIF () ELSE () - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -malign-stringops -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") + ENDIF () + ADD_DEFINITIONS(-DLINUX) + ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) + ELSEIF (TD_LINUX_32) + IF (NOT TD_ARM) + EXIT () ENDIF () + SET(DEBUG_FLAGS "-O0 -DDEBUG") + SET(RELEASE_FLAGS "-O0") + SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") ADD_DEFINITIONS(-DLINUX) ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT) + ADD_DEFINITIONS(-DUSE_LIBICONV) ELSEIF (TD_WINDOWS_64) SET(CMAKE_GENERATOR "NMake Makefiles" CACHE INTERNAL "" FORCE) SET(COMMON_FLAGS "/nologo /WX- /Oi /Oy- /Gm- /EHsc /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /errorReport:prompt /analyze-") @@ -120,7 +171,7 @@ IF (NOT DEFINED TD_CLUSTER) ADD_DEFINITIONS(-DPTW32_BUILD) ADD_DEFINITIONS(-D_MBCS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) ELSEIF (TD_DARWIN_64) - SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -Wno-char-subscripts -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-unused-variable -Wno-bitfield-constant-conversion") + SET(COMMON_FLAGS "-std=gnu99 -Wall -fPIC -malign-double -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE") SET(DEBUG_FLAGS "-O0 -DDEBUG") SET(RELEASE_FLAGS "-O0") ADD_DEFINITIONS(-DDARWIN) @@ -169,6 +220,14 @@ IF (NOT DEFINED TD_CLUSTER) INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})") INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})") + ELSEIF (TD_LINUX_32) + IF (NOT TD_ARM) + EXIT () + ENDIF () + SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") + INSTALL(CODE "MESSAGE(\"make install script: ${TD_MAKE_INSTALL_SH}\")") + INSTALL(CODE "execute_process(COMMAND chmod 777 ${TD_MAKE_INSTALL_SH})") + INSTALL(CODE "execute_process(COMMAND ${TD_MAKE_INSTALL_SH} ${TD_COMMUNITY_DIR} ${PROJECT_BINARY_DIR})") ELSEIF (TD_WINDOWS_64) SET(CMAKE_INSTALL_PREFIX C:/TDengine) INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector) diff --git a/README.md b/README.md index c82cda6f3cafe148c317b132edcb7041137670e0..fddd7d31322911947815ba8589374666b88e5d69 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,18 @@ sudo apt-get install maven ``` Build TDengine: -```cmd +``` mkdir build && cd build cmake .. && cmake --build . ``` +if compiling on an arm64 processor, you need add one parameter: + +```cmd +cmake .. -DARMVER=arm64 && cmake --build . +``` + # Quick Run To quickly start a TDengine server after building, run the command below in terminal: ```cmd diff --git a/documentation/tdenginedocs-cn/connector/index.html b/documentation/tdenginedocs-cn/connector/index.html index fca343e977fa48fc9b1a6fc4bb55e23c0056fe7b..3167c1521f099f8acd7ae237cc37bd5867ee209a 100644 --- a/documentation/tdenginedocs-cn/connector/index.html +++ b/documentation/tdenginedocs-cn/connector/index.html @@ -114,23 +114,84 @@ public Connection getConn() throws Exception{
对于TDengine操作的报错信息,用户可使用JDBCDriver包里提供的枚举类TSDBError.java来获取error message和error code的列表。对于更多的具体操作的相关代码,请参考TDengine提供的使用示范项目JDBCDemo
。
用户可以在源代码的src/connector/python文件夹下找到python2和python3的安装包。用户可以通过pip命令安装:
- pip install src/connector/python/python2/
或
- pip install src/connector/python/python3/
如果机器上没有pip命令,用户可将src/connector/python/python3或src/connector/python/python2下的taos文件夹拷贝到应用程序的目录使用。
-在使用TDengine的python接口时,需导入TDengine客户端模块:
-import taos
-用户可通过python的帮助信息直接查看模块的使用信息,或者参考code/examples/python中的示例程序。以下为部分常用类和方法:
+用户可以在源代码的src/connector/python文件夹下找到python2和python3的安装包, 然后通过pip命令安装
+pip install src/connector/python/linux/python2/
+或者
+pip install src/connector/python/linux/python3/
+在已安装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文件夹拷贝到应用程序的目录使用。
+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
+
+# 创建数据库
+c1.execute('create database db')
+c1.execute('use db')
+# 建表
+c1.execute('create table tb (ts timestamp, temperature int, humidity float)')
+# 插入数据
+start_time = datetime.datetime(2019, 11, 1)
+affected_rows = c1.execute('insert into tb values (\'%s\', 0, 0.0)' %start_time)
+# 批量插入数据
+time_interval = datetime.timedelta(seconds=60)
+sqlcmd = ['insert into tb values']
+for irow in range(1,11):
+ start_time += time_interval
+ sqlcmd.append('(\'%s\', %d, %f)' %(start_time, irow, irow*1.2))
+affected_rows = c1.execute(' '.join(sqlcmd))
+
+
+c1.execute('select * from tb')
+# 拉取查询结果
+data = c1.fetchall()
+# 返回的结果是一个列表,每一行构成列表的一个元素
+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])
+
+# 直接使用cursor 循环拉取查询结果
+c1.execute('select * from tb')
+for data in c1:
+ print("ts=%s, temperature=%d, humidity=%f" %(data[0], data[1],data[2])
+
+
+c1.close()
+conn.close()
+
+用户可通过python的帮助信息直接查看模块的使用信息,或者参考code/examples/python中的示例程序。以下为部分常用类和方法:
TaosConnection类
-参考python中help(taos.TaosConnection)。
TaosCursor类
-参考python中help(taos.TaosCursor)。
connect方法
-用于生成taos.TaosConnection的实例。
TaosConnection 类
+参考python中help(taos.TDengineConnection)
TaosCursor 类
+参考python中help(taos.TDengineCursor)
connect 方法
+用于生成taos.TDengineConnection的实例。
为支持各种不同类型平台的开发,TDengine提供符合REST设计标准的API,即RESTful API。为最大程度降低学习成本,不同于其他数据库RESTful API的设计方法,TDengine直接通过HTTP POST 请求BODY中包含的SQL语句来操作数据库,仅需要一个URL。
diff --git a/documentation/tdenginedocs-cn/getting-started/index.html b/documentation/tdenginedocs-cn/getting-started/index.html index d7e8fe311c7ad9a78605163903fa0f9378c70544..d7d5d8540c6c46bbf5210677339c2ee202a7ec86 100644 --- a/documentation/tdenginedocs-cn/getting-started/index.html +++ b/documentation/tdenginedocs-cn/getting-started/index.html @@ -28,7 +28,7 @@在TDengine终端中,用户可以通过SQL命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的SQL语句需要以分号结束来运行。示例:
create database db;
use db;
-create table t (ts timestamp, cdata int);
+create table t (ts timestamp, speed int);
insert into t values ('2019-07-15 00:00:00', 10);
insert into t values ('2019-07-15 01:00:00', 20);
select * from t;
@@ -63,7 +63,7 @@ Query OK, 2 row(s) in set (0.001700s)
TDengine的核心功能是时序数据库。除此之外,为减少研发的复杂度、系统维护的难度,TDengine还提供缓存、消息队列、订阅、流式计算等功能。更详细的功能如下:
TDengine是专为物联网、车联网、工业互联网、运维监测等场景优化设计的时序数据处理引擎。与其他方案相比,它的插入查询速度都快10倍以上。单核一秒钟就能插入100万数据点,读出1000万数据点。由于采用列式存储和优化的压缩算法,存储空间不及普通数据库的1/10.
请继续阅读文档来深入了解TDengine。
回去