diff --git a/src/connector/odbc/README.md b/src/connector/odbc/README.md new file mode 100644 index 0000000000000000000000000000000000000000..be3812e1e93490dfb024af09a1d8ce5a3d7d5bd2 --- /dev/null +++ b/src/connector/odbc/README.md @@ -0,0 +1,82 @@ + +# ODBC Driver # + +- **very initial implementation of ODBC driver for TAOS + +- **currently partially supported ODBC functions are: ` +SQLAllocEnv +SQLFreeEnv +SQLAllocConnect +SQLFreeConnect +SQLConnect +SQLDisconnect +SQLAllocStmt +SQLAllocHandle +SQLFreeStmt +SQLExecDirect +SQLExecDirectW +SQLNumResultCols +SQLRowCount +SQLColAttribute +SQLGetData +SQLFetch +SQLPrepare +SQLExecute +SQLGetDiagField +SQLGetDiagRec +SQLBindParameter +SQLDriverConnect +SQLSetConnectAttr +SQLDescribeCol +SQLNumParams +SQLSetStmtAttr +` + +- **internationalized, you can specify different charset/code page for easy going. eg.: insert `utf-8.zh_cn` characters into database located in linux machine, while query them out in `gb2312/gb18030/...` code page in your chinese windows machine, or vice-versa. and much fun, insert `gb2312/gb18030/...` characters into database located in linux box from +your japanese windows box, and query them out in your local chinese windows machine. + +- **enable ODBC-aware software to communicate with TAOS. + +- **enable any language with ODBC-bindings/ODBC-plugings to communicate with TAOS + +- **still going on... + +# Building and Testing +**Note**: all `work` is done in TDengine's project directory + + +# Building under Linux, use Ubuntu as example +``` +sudo apt install unixodbc unixodbc-dev flex +rm -rf debug && cmake -B debug && cmake --build debug && cmake --install debug && echo yes +``` +# Building under Windows, use Windows 10 as example +- install windows `flex` port. We use [https://github.com/lexxmark/winflexbison](url) at the moment. Please be noted to append `` to your `PATH`. +- install Microsoft Visual Studio, take VS2015 as example here +- `"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64` +- `rmdir /s /q debug` +- `cmake -G "NMake Makefiles" -B debug` +- `cmake --build debug` +- `cmake --install debug` +- open your `Command Prompt` with Administrator's privilidge +- remove previously installed TAOS ODBC driver: run `C:\TDengine\todbcinst -u -f -n TAOS` +- install TAOS ODBC driver that was just built: run `C:\TDengine\todbcinst -i -n TAOS -p C:\TDengine\driver` + +# Test +we highly suggest that you build both in linux(ubuntu) and windows(windows 10) platform, because currently TAOS only has it's server-side port on linux platform. +**Note1**: content within <> shall be modified to match your environment +**Note2**: `.stmts` source files are all encoded in `UTF-8` +## start taosd in linux, suppose charset is `UTF-8` as default +``` +taosd -c ./debug/test/cfg +``` +## create data in linux +``` +./debug/build/bin/tcodbc 'Driver=TAOS;UID=;PWD=;Host=:6030;server_enc=UTF-8' ./src/connector/odbc/tests/create_data.stmts +``` +## query data in windows +``` +.\debug\build\bin\tcodbc "Driver=TAOS;UID=;PWD=;Host=:6030;server_enc=UTF-8" .\src\connector\odbc\tests\query_data.stmts +``` + + diff --git a/src/connector/odbc/tests/main.c b/src/connector/odbc/tests/main.c index 2c817f13858d043e12efb50adf36146dbcc4a46c..74bceaaf3177737be4a6f8176a5372e8e356592b 100644 --- a/src/connector/odbc/tests/main.c +++ b/src/connector/odbc/tests/main.c @@ -16,7 +16,10 @@ do { \ D("testing: %s", #statement); \ int r = (statement); \ - if (r) return 1; \ + if (r) { \ + D("testing failed: %s", #statement); \ + return 1; \ + } \ } while (0); @@ -543,6 +546,7 @@ int main(int argc, char *argv[]) { CHK_TEST(test_sqls(dsn, uid, pwd, connstr, sqls)); } + D("Done!"); return 0; } diff --git a/src/connector/odbc/tools/main.c b/src/connector/odbc/tools/main.c index b9422830c047b0361a68b090829ab3fcc7aa21ee..7b8421c4e1d54d33a88ca1805e7e4871e1447876 100644 --- a/src/connector/odbc/tools/main.c +++ b/src/connector/odbc/tools/main.c @@ -113,6 +113,8 @@ static int do_install(int i, int argc, char *argv[]) { return -1; } + fprintf(stderr, "ODBC driver [%s] has been installed in [%s], and UsageCount is now [%d]\n", + driverName, driverPath, usageCount); return argc; } @@ -152,8 +154,12 @@ static int do_uninstall(int i, int argc, char *argv[]) { fprintf(stderr, "failed to remove driver [%s]\n", driverName); return -1; } - if (!forceful) return argc; + if (!forceful) { + fprintf(stderr, "UsageCount for ODBC driver [%s] is now: [%d]\n", driverName, usageCount); + return argc; + } } while (usageCount > 0); + fprintf(stderr, "ODBC driver [%s] is now fully uninstalled\n", driverName); return argc; }