# Using the kodbc driver

This section describes how to use the sample c program 'csvupload' to send the data from the sample.csv file to the sdk_sample_assembly inside the KX Insights Platform, which can be downloaded using the instructions here.

The kodbc driver samples-${VERSION}.zip file, downloaded from the KX Insights Nexus registry, contains the following files: • csvupload.c - csv upload source code. • CMakeLists.txt - cmake file. • sample.csv - sample data based on the sdk_sample_assembly which can be downloaded using the instructions here. Note Before using the sample program you need to download and install the kodbc driver as described here. The source code can be taken and edited for use inside your applications. ### Prerequisites Before building the sample program the following pre-requisites are required: • kodbc driver • unixodbc package • unixodbc-dev package • cmake package • libcsv-dev package • libcsv package ### Building Once these are installed: • Extract the files from the zip file • Move to the extracted folder • Build the application: cmake --clean-first --build . && make  ### Application parameters • -c str, ODBC connection string • -t str, Table name • -s str, Schema (e.g., field1:datatype,field2:datatype) Note The schema must match that defined in the pipeline assembly. For the SDK, described here, the schema definition is as follows: sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:int,alarm:int #### ODBC connection string parameters The following list includes the recognized ODBC connection string parameters that can be included in the -c parameter: parameter default description DRIVER none Path to the driver file. URL none URL of the configuration file. In the form: 'https://{INSIGHTS_HOSTNAME}/informationservice/details/{KC_CLIENT_ID}'. RTDIR /tmp/rt Path to the RT log directory. CONF_SLEEP 5000 Time in ms to sleep between fetches of the configuration details from the Information Service. CONF_MAX_AGE 300000 Maximum age of configuration details in ms. After this amount of time, if still unable to fetch a new configuration, the connection is considered to be broken and any subsequent attempts to send data to the KX Insights Platform will fail with Not connected error. LOCAL_PERSIST_PERIOD 600000 Local persistence period (in milliseconds) TIMEOUT 2000 Connection timeout in ms. LOG info Log level (example: "info", "err", "warn") The URL is mandatory, as well as one of the following: DRIVER or DSN. ### Supported data types The following data types are supported by the sample application: type schema notation example string string name symbol symbol LLOY int int 1 byte byte 0 long long 200000 float float 1.2345 timestamp ts 2000.01.01D00:00:00.000000000 ### Publishing data using csvupload In the example below the environment variables INSIGHTS_HOSTNAME and INSIGHTS_CLIENT_URL have been initialized. DSN="DRIVER=/usr/local/lib/kodbc/libkodbc.so;URL=https://{INSIGHTS_HOSTNAME}/informationservice/details/{KC_CLIENT_ID}" Schema="sensorID:int,captureTS:ts,readTS:ts,valFloat:float,qual:byte,alarm:byte" Table="trace" ./csvupload -c "$DSN" -t "$Table" -s "$Schema" < sample.csv

The path to the DRIVER may be different in your environment.