Installation
The module requires Go 1.26 or later. Add it to a project withgo get:
Import
Supporting Packages
Connecting
A connection is made withConnect, given the URL of a Kinetica database
server and the connection options, which carry the credentials. Connect
discovers the clusters of the HA ring and the worker ranks of each, and reads
the server version; it fails if no server answers.
Close drops them. A connection is safe for concurrent
use.
For connecting over HTTPS, with or without certificate validation, and with an
OAuth token, see Connecting via API. For failover
across an HA ring, give Connect the head node of each cluster, or let it
discover the ring from one.
Using the API
The following walks through the operations of the quick start example, which creates a table, loads it, queries it, and drops it.Tables & Types
A table’s record type can be defined from a Go struct. Each exported field is a column, named and given column properties by itskinetica tag; a pointer field is nullable.
TypeBuilder, or read from
an existing table with NewTypeFromTable.
Inserting Records
Records of the struct type are inserted in one request withInsertRecordsTyped:
Bulk Loading
For loading many records, aBulkInserter batches them and sends each batch
directly to the worker rank that holds it, using
distributed ingest.
Insert queues a record; Close flushes what is buffered, waits for every
batch, and returns the batches that failed, if any.
Querying with SQL
Query runs a SQL query and returns an iterator over its records, which are
read from the server a batch at a time. The iterator must be closed, which
drops the paging table the query made.
Execute runs any other SQL statement and returns the number of records it
affected. The WithParameters form of each takes the values for the ?
placeholders in the statement, sent as the
query parameters of the request:
SQLParametersValues sends the values as text, which the server converts to
the column types; SQLParametersJSON sends typed values, nulls, and slices
for several rows.
The full SQL feature set is available through these calls; see the
SQL section for the language.
Retrieving Records
GetRecordsTyped reads records back into the struct, matching each column to
the field of its name. The options take a filter expression and a sort order,
among others.
Dropping a Table
Errors
Every call returns a*kinetica.Error, which carries a kind and a message:
an API error for a request the server refused, Unauthorized for a
rejected login, Connection for a request that got no response, and so on.
errors.Is finds a kind anywhere in an error’s chain, and errors.As
reaches the error itself:
Error Handling