Giter Club home page Giter Club logo

taos_odbc2's Introduction

ODBC Driver for TDengine 3.0 (TAOS)

English | 简体中文

Supported platform

  • Linux
  • macOS
  • Windows

Features

  • on-going implementation of ODBC driver for TDengine 3.0 (TAOS)
  • currently exported ODBC functions are:
ConfigDSN              (windows port only)
ConfigDriver           (windows port only)
ConfigTranslator       (windows port only)
SQLAllocHandle
SQLBindCol
SQLBindParameter
SQLBrowseConnect
SQLBulkOperations
SQLCloseCursor
SQLColAttribute
SQLColumnPrivileges
SQLColumns
SQLCompleteAsync
SQLConnect
SQLCopyDesc
SQLDescribeCol
SQLDescribeParam
SQLDisconnect
SQLDriverConnect
SQLEndTran
SQLExecDirect
SQLExecute
SQLExtendedFetch
SQLFetch
SQLFetchScroll
SQLForeignKeys
SQLFreeHandle
SQLFreeStmt
SQLGetConnectAttr
SQLGetCursorName
SQLGetData
SQLGetDescField
SQLGetDescRec
SQLGetDiagField
SQLGetDiagRec
SQLGetEnvAttr
SQLGetInfo
SQLGetStmtAttr
SQLGetTypeInfo
SQLMoreResults
SQLNativeSql
SQLNumParams
SQLNumResultCols
SQLParamData
SQLPrepare
SQLPrimaryKeys
SQLProcedureColumns
SQLProcedures
SQLPutData
SQLRowCount
SQLSetConnectAttr
SQLSetCursorName
SQLSetDescField
SQLSetDescRec
SQLSetEnvAttr
SQLSetPos
SQLSetStmtAttr
SQLSpecialColumns
SQLStatistics
SQLTablePrivileges
SQLTables (post-filter workaround, to be removed when taosc is right in place)
  • enable ODBC-aware software to communicate with TDengine
  • enable any programming language with ODBC-bindings/ODBC-plugings to communicate with TDengine. programming languages listed as follows are demonstrated in test-cases:
programming language ODBC-API or bindings/plugins
C/C++ ODBC-API
CSharp System.Data.Odbc
Erlang odbc module
Go github.com/alexbrainman/odbc, database/sql
Haskell HDBC, HDBC-odbc
Common Lisp plain-odbc
Nodejs odbc
Python3 pyodbc
Rust odbc
  • On Windows, "ODBC Data Sources (64bit)" pre-installed tool can be used to manage DSN
  • Support TDengine data subscription feature,refer to samples/c/demo_topic.c
  • still going on...

Requirements

Installing TDengine 3.0

  • please visit https://tdengine.com
  • better use TDengine-git-commit "ea249127afb42ac3a31d8d9f63243c3d1b950b5d" or above, otherwise, you might come across memory leakage in windows platform, which is introduced by taos_stmt_get_tag_fields/taos_stmt_get_col_fields. please check detail: taosdata/TDengine#18804 and taosdata/TDengine#19245

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

  • TAOS_ODBC_LOG_LEVEL: VERBOSE/DEBUG/INFO/WARN/ERROR/FATAL, from low to high. the lower the level is, the more info to log
  • TAOS_ODBC_LOGGER: stderr/temp/syslog
    • stderr: log to stderr
    • temp: log to env('TEMP')/taos_odbc.log or /tmp/taos_odbc.log if env('TEMP') not exists
    • syslog: log to syslog

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

  • TAOS_ODBC_LOG_LEVEL: VERBOSE/DEBUG/INFO/WARN/ERROR/FATAL, from low to high. the lower the level is, the more info to log
  • TAOS_ODBC_LOGGER: stderr/temp
    • stderr: log to stderr
    • temp: log to env('TEMP')/taos_odbc.log or /tmp/taos_odbc.log if env('TEMP') not exists

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\TAOS_ODBC_DRIVER
HKEY_CURRENT_USER\Software\ODBC\Odbc.ini\TAOS_ODBC_DSN

Test

  1. setup testing environment variable TAOS_ODBC_LOG_LEVEL and TAOS_ODBC_LOGGER
  • TAOS_ODBC_LOG_LEVEL: VERBOSE/DEBUG/INFO/WARN/ERROR/FATAL, from low to high. the lower the level is, the more info to log
  • TAOS_ODBC_LOGGER: stderr/temp
    • stderr: log to stderr
    • temp: log to env('TEMP')\taos_odbc.log or C:\Windows\Temp\taos_odbc.log if env('TEMP') not exists
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

  • cmake --help or man cmake
  • ctest --help or man ctest
  • valgrind --help or man valgrind

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
│   ├── rust
│   │   └── main
│   │       └── src
│   └── taos
└── valgrind

TDengine references

ODBC references

taos_odbc2's People

Contributors

freemine avatar facetosea avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.