Home

Awesome

ODBC Driver for TDengine 3.0 (TAOS)

English | 简体中文

Supported platform

Features

ODBC/Setup APIlinux (ubuntu 22.04)macosx (ventura 13.2.1)windows 11note
ConfigDSN
ConfigDriver
ConfigTranslator
SQLAllocHandle
SQLBindColColumn-Wise Binding only
SQLBindParameterColumn-Wise Binding only
SQLBrowseConnect
SQLBulkOperationsTDengine has no counterpart
SQLCloseCursor
SQLColAttribute
SQLColumnPrivilegesTDengine seems have no strict counterpart
SQLColumns
SQLCompleteAsync
SQLConnect
SQLCopyDesc
SQLDescribeCol
SQLDescribeParampartially and on-going
SQLDisconnect
SQLDriverConnect
SQLEndTranTDengine is non-transactional, thus this is at most simulating
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScrollTDengine has no counterpart, just implement SQL_FETCH_NEXT
SQLForeignKeysTDengine has no counterpart
SQLFreeHandle
SQLFreeStmt
SQLGetConnectAttrpartially and on-going
SQLGetCursorNameTDengine has no counterpart
SQLGetData
SQLGetDescField
SQLGetDescRec
SQLGetDiagField
SQLGetDiagRec
SQLGetEnvAttrpartially and on-going
SQLGetInfopartially and on-going
SQLGetStmtAttrpartially and on-going
SQLGetTypeInfo
SQLMoreResults
SQLNativeSqlTDengine has no counterpart
SQLNumParamsTDengine has partially support, thus workaround in some cases
SQLNumResultCols
SQLParamDataTDengine has no counterpart
SQLPrepareTDengine has partially support, thus workaround in some cases
SQLPrimaryKeys
SQLProcedureColumnsTDengine has no counterpart
SQLProceduresTDengine has no counterpart
SQLPutDataTDengine has no counterpart
SQLRowCount
SQLSetConnectAttrpartially and on-going
SQLSetCursorNameTDengine has no counterpart
SQLSetDescField
SQLSetDescRec
SQLSetEnvAttrpartially and on-going
SQLSetPosTDengine has no counterpart
SQLSetStmtAttrpartially and on-going
SQLSpecialColumnsTDengine has no counterpart
SQLStatisticsTDengine has no counterpart
SQLTablePrivilegesTDengine has no strict counterpart
SQLTables
AttributeNote
SQL_ATTR_CONCURRENCYTDengine has no updatable-CURSOR machanism
SQL_ATTR_FETCH_BOOKMARK_PTRTDengine has no BOOKMARK machanism
SQL_ATTR_IMP_PARAM_DESC
SQL_ATTR_IMP_ROW_DESC
SQL_ATTR_KEYSET_SIZE
SQL_ATTR_PARAM_BIND_OFFSET_PTR
SQL_ATTR_PARAM_OPERATION_PTR
SQL_ATTR_ROW_NUMBERReadonly attribute
SQL_ATTR_ROW_OPERATION_PTR
SQL_ATTR_SIMULATE_CURSOR
AttributeNote
SQL_ATTR_AUTO_IPDReadonly attribute
SQL_ATTR_CONNECTION_DEADReadonly attribute
SQL_ATTR_ENLIST_IN_DTC
SQL_ATTR_PACKET_SIZE
SQL_ATTR_TRACE
SQL_ATTR_TRACEFILE
SQL_ATTR_TRANSLATE_LIB
SQL_ATTR_TRANSLATE_OPTION
programming languageODBC-API or bindings/plugins
C/C++ODBC-API
CSharpSystem.Data.Odbc
Erlangodbc module
Gogithub.com/alexbrainman/odbc, database/sql
HaskellHDBC, HDBC-odbc
Common Lispplain-odbc
Nodejsodbc
Python3pyodbc
Rustodbc

Requirements

Installing TDengine 3.0

Installing prerequisites, use Ubuntu 20.04 as an example

sudo apt install flex bison unixodbc unixodbc-dev && echo -=Done=-

Building and Installing, use Ubuntu 20.04 as an example

rm -rf debug &&
cmake -B debug -DCMAKE_BUILD_TYPE=Debug &&
cmake --build debug &&
sudo cmake --install debug &&
cmake --build debug --target install_templates &&
echo -=Done=-

Test

pushd debug >/dev/null && TAOS_TEST_CASES=$(pwd)/../tests/taos/taos_test.cases ODBC_TEST_CASES=$(pwd)/../tests/c/odbc_test.cases ctest --output-on-failure && echo -=Done=-; popd >/dev/null

Test with environment variable TAOS_ODBC_LOG_LEVEL and TAOS_ODBC_LOGGER

in case when some test cases fail and you wish to have more debug info, such as when and how taos_xxx API is called under the hood, you can

pushd debug >/dev/null && TAOS_TEST_CASES=$(pwd)/../tests/taos/taos_test.cases ODBC_TEST_CASES=$(pwd)/../tests/c/odbc_test.cases TAOS_ODBC_LOG_LEVEL=ERROR TAOS_ODBC_LOGGER=stderr ctest --output-on-failure && echo -=Done=-; popd >/dev/null

To make your daily life better

export TAOS_TEST_CASES=$(pwd)/tests/taos/taos_test.cases
export ODBC_TEST_CASES=$(pwd)/tests/c/odbc_test.cases
export TAOS_ODBC_LOG_LEVEL=ERROR
export TAOS_ODBC_LOGGER=stderr

and then, you can

pushd debug >/dev/null && ctest --output-on-failure && echo -=Done=-; popd >/dev/null

Installing prerequisites, use MacOS Big Sur as an example

brew install flex bison unixodbc && echo -=Done=-

Building and Installing, use MacOS Big Sur as an example

rm -rf debug &&
cmake -B debug -DCMAKE_BUILD_TYPE=Debug &&
cmake --build debug &&
sudo cmake --install debug &&
cmake --build debug --target install_templates &&
echo -=Done=-

Test

pushd debug >/dev/null && TAOS_TEST_CASES=$(pwd)/../tests/taos/taos_test.cases ODBC_TEST_CASES=$(pwd)/../tests/c/odbc_test.cases ctest --output-on-failure && echo -=Done=-; popd >/dev/null

Test with environment variable TAOS_ODBC_LOG_LEVEL and TAOS_ODBC_LOGGER

in case when some test cases fail and you wish to have more debug info, such as when and how taos_xxx API is called under the hood, you can

pushd debug >/dev/null && TAOS_TEST_CASES=$(pwd)/../tests/taos/taos_test.cases ODBC_TEST_CASES=$(pwd)/../tests/c/odbc_test.cases TAOS_ODBC_LOG_LEVEL=ERROR TAOS_ODBC_LOGGER=stderr ctest --output-on-failure && echo -=Done=-; popd >/dev/null

To make your daily life better

export TAOS_TEST_CASES=$(pwd)/tests/taos/taos_test.cases
export ODBC_TEST_CASES=$(pwd)/tests/c/odbc_test.cases
export TAOS_ODBC_LOG_LEVEL=ERROR
export TAOS_ODBC_LOGGER=stderr

and then, you can

pushd debug >/dev/null && ctest --output-on-failure && echo -=Done=-; popd >/dev/null

Installing prerequisites, use Windows 11 as an example

  1. download and install win_flex_bison 2.5.25.
https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip
  1. check to see if it's installed:
win_flex --version

Building and Installing, use Windows 11 as an example

  1. Open Command Prompt as an Administrator. https://www.makeuseof.com/windows-run-command-prompt-admin/
  2. change to the root directory of this project
  3. optionally, setup building environment, if you install visual studio community 2022 on a 64-windows-platform, then:
"\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
  1. generate make files
cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -B build -G "Visual Studio 17 2022" -A x64

TroubleShooting: if compiler error occurs during the following steps, such as: <path_to_winbase.h>: warning C5105: macro expansion producing 'defined' has undefined behavior, you can retry as below:

cmake --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -B build -G "Visual Studio 17 2022" -A x64 -DDISABLE_C5105:BOOL=ON
  1. building project
cmake --build build --config Debug -j 4
  1. installing taos_odbc, this would install taos_odbc.dll into C:\Program Files\taos_odbc\bin\
cmake --install build --config Debug
cmake --build build --config Debug --target install_templates
  1. check and see if a new TAOS_ODBC_DSN registry has been setup in win_registry
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\TDengine
HKEY_CURRENT_USER\Software\ODBC\Odbc.ini\TAOS_ODBC_DSN

Test

  1. setup testing environment variable TAOS_ODBC_LOG_LEVEL and TAOS_ODBC_LOGGER
set TAOS_TEST_CASES=%cd%\tests\taos\taos_test.cases
set ODBC_TEST_CASES=%cd%\tests\c\odbc_test.cases
set TAOS_ODBC_LOG_LEVEL=ERROR
set TAOS_ODBC_LOGGER=stderr
  1. testing
ctest --test-dir build --output-on-failure -C Debug

Tips

Layout of source code, directories only

<root>
├── benchmark
├── cmake
├── common
├── inc
├── samples
│   └── c
├── sh
├── src
│   ├── core
│   ├── inc
│   ├── os_port
│   ├── parser
│   ├── tests
│   └── utils
├── templates
├── tests
│   ├── c
│   ├── cpp
│   ├── cs
│   ├── erl
│   ├── go
│   ├── hs
│   │   └── app
│   ├── lisp
│   ├── node
│   ├── python
│   ├── R
│   ├── rust
│   │   └── main
│   │       └── src
│   ├── taos
│   └── ws
└── valgrind

TDengine references

ODBC references

originally initiated by freemine@yeah.net