Call Level Interface SDK
This article describes the Exasol Call Level Interface SDK.
Exasol provides a Call Level Interface software development kit (SDK) to connect client applications to Exasol. You can download CLI SDK versions for Windows and Linux/FreeBSD from the Exasol Downloads Portal .
Exasol CLI is a native C++ interface that implements most of the ODBC variation of the SQL Call Level Interface standard. The interface functions are similar to the ODBC functions but use the prefix EXA
.
Some of the advantages of the Exasol CLI are:
- Exasol CLI is faster than ODBC and JDBC
- Special Exasol features such as batch execution, parallel reading, and parallel insertion are supported
- An ODBC programmer can quickly become familiar with the Exasol CLI
Exasol CLI for Windows
Exasol CLI for Windows is tested on the following Windows versions:
Windows (64-bit)
-
Windows 10
-
Windows Server 2016
-
Windows Server 2019
-
Windows Server 2022
Windows (32-bit)
-
Windows 10
Prerequisites
Microsoft .NET Framework 4.6.2 must be installed on your system.
Installation
The CLI SDK package is part of Exasol ODBC package version 24.0.0 and later. Exasol ODBC Driver version 24+ is recommended for all Exasol database versions. You can download the latest ODBC driver package from Exasol Downloads.
Older (legacy) version of the SDK are also available on Exasol Downloads. We recommend that you use the latest version provided with the ODBC driver package.
After installing the ODBC driver, you will find the SDK package in the ODBC installation folder. The default location is:
C:\Program Files\Exasol\ODBC\SDK
The SDK package includes the following:
-
The header files
exaCInterface.h
andexaDefs.h
. These files contain declarations and constants of Exasol CLI. -
A fully functional sample program illustrating integration of the CLI interface. The sample is provided as source code (
exaexec.c
) and includes a project file for Visual Studio 10 (sqlExec.vcxproj
). -
Documentation in HTML format
The necessary Windows libraries, such as EXACLI.lib
and EXACLI.dll
, are located in the main ODBC installation directory.
Compile and run a sample program
Visual Studio 10 or later must be installed on your system.
Open the project file sqlExec.vcxproj
in the folder examples\sqlExec\
with Visual Studio.
The sample source file exaexec.c
is already integrated in the project. The lib and include paths should point to the corresponding folders that were installed with the CLI. If you have moved or changed the files from the CLI package you must update the project accordingly.
You can compile the sample program for 32-bit and 64-bit as a debug and release version. The generated .exe
file is a standard Windows console application. The source code of the sample program contains comments that describe the parts of the application.
Example:
This example submits the SQL string select * from exa_syscat
through standard-in to the sample program sqlExec.exe
and through the CLI function. EXAExecDirect()
is then executed in Exasol.
Exasol CLI for Linux/FreeBSD
Exasol CLI for Linux/FreeBSD is tested on the following OS versions:
- Linux
-
CentOS 7
-
CentOS 8 Stream
-
OpenSUSE 15
-
Debian 10
-
Ubuntu 20.04 LTS
-
Ubuntu 22.04 LTS
-
FreeBSD
-
FreeBSD 13.2
-
FreeBSD 14.0
Installation
The CLI SDK package is part of Exasol ODBC package version 24.0.0 and later. Exasol ODBC Driver version 24+ is recommended for all Exasol database versions. You can download the latest ODBC driver package from Exasol Downloads.
Older (legacy) version of the SDK are also available on Exasol Downloads. We recommend that you use the latest version provided with the ODBC driver package.
Extract the ODBC package in a directory using tar -xzf Exasol_ODBC-<version>.tar.gz
.
After extracting the ODBC package you will find the SDK package in Exasol_ODBC-<version>/SDK
.
The SDK package includes the following:
-
Exasol libraries supporting unixODBC Driver Manager, such as
libexacli.so
andlibexaodbc.so
-
The header files
exaCInterface.h
andexaDefs.h
. These files contain declarations and constants of Exasol CLI. -
A sample program illustrating integration of Exasol CLI. The sample is provided as source code
exaexec.c
with makefiles for Linux and FreeBSD. -
Documentation in HTML format
Compile and run a sample program
Compile the sample program using the appropriate makefile for Linux or FreeBSD.
Example 1
The following example executes the SQL statement select * from exa_syscat
and returns the number of columns and rows of the result.
Results:
RESULTCOLS=3 |
ROWS=83 |
PARAMCOUNT=0 |
Example 2
The following example illustrates how to send SQL queries to the database. The return values are not checked to simplify the code.
// Like in the ODBC interface, handles are created before the connection
// is established (for environment and connection)
SQLHENV henv;
SQLHDBC hdbc;
EXAAllocHandle(SQL_HANDLE_ENV, NULL, &henv);
EXAAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
// Connect to a cluster with 3 nodes
EXAServerConnect(hdbc, "192.168.6.11..14:8563", SQL_NTS, NULL,
0, "sys", SQL_NTS, "exasol", SQL_NTS);
// Create a SQL statement handle
SQLHSTMT hstmt;
EXAAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
// Create schema "TEST"
EXAExecDirect(hstmt, (SQLCHAR*)"CREATE SCHEMA test", SQL_NTS);
// Free the resources and close the connection
EXAFreeHandle(SQL_HANDLE_STMT, hstmt);
EXADisconnect(hdbc);
EXAFreeHandle(SQL_HANDLE_DBC, hdbc);
EXAFreeHandle(SQL_HANDLE_ENV, henv);
Best practices
Reading big data volumes
-
Always use
SQLBindCol
andSQLFetch
instead ofSQLGetData
. -
For best performance, try to fetch 50 to 100 MiB of data by choosing the number of rows per
SQLFetch.
Inserting data into the database
-
Instead of using single insert statements like
INSERT INTO t VALUES 1, 2, ...
, use the more efficient interface of prepared statements and their parameters. Prepared statements achieve optimal performance when using parameter sets between 50 MiB and 100 MiB. -
Insert data using native data types. For example, for the number
1234
, use the integer data typeSQL_C_SLONG
(1234
) instead ofSQL_CHAR
("1234"
).