> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ADBC Driver Guide

*Kinetica* provides an Arrow-native SQL interface through its [ADBC](https://arrow.apache.org/adbc/)
(*Arrow Database Connectivity*) driver, which runs on *Linux*, *Mac*, &
*Windows*.  Query results arrive from the database as Arrow record batches,
with no row-by-row conversion in between, and bulk loads go directly to the
worker ranks that hold each row.  The driver is built on the *Kinetica*
[Rust API](https://crates.io/crates/gpudb-api).

Clients that can't use ADBC can connect using the
[JDBC Connector](https://docs.kinetica.com/content/connectors/sql_guide.md) or the
[PostgreSQL Wire Protocol](https://docs.kinetica.com/content/connectors/psql_wire_protocol.md).  For
details on the extent of SQL compliance, see the [SQL](https://docs.kinetica.com/content/sql.md) section.

## Requirements

The driver requires *Kinetica* 7.2.3.24 or later, the first version to return
query results as Arrow.  A connection to an older server is refused when it
opens, with an error naming the version found and the version needed.

The driver's version follows *Kinetica*'s:  the `7.2.<X>` releases are for
*Kinetica* 7.2, with `<X>` counting the driver's own releases.

## Installation

### Python

The driver is available on [PyPI](https://pypi.org/project/adbc-driver-kinetica/) as a package that bundles the driver for
the local platform with the ADBC driver manager:

```
pip3 install adbc-driver-kinetica
```

To add *pandas* support for `fetch_df`:

```
pip3 install "adbc-driver-kinetica[dataframe]"
```

To take every release for *Kinetica* 7.2 and none for a later version:

```
pip3 install "adbc-driver-kinetica~=7.2.0"
```

Wheels are published for *Linux* (x86-64 & ARM64), *Mac* (Apple silicon), &
*Windows* (x86-64), for *Python* 3.11 or later.

> [!NOTE]
>
> There is no *Windows* ARM64 wheel, as `pyarrow` publishes none; on
> that platform, use the x86-64 wheel under an x86-64 *Python*, or
> install the driver with [dbc](https://docs.columnar.tech/dbc), below.

### Other Languages

The driver is built & distributed by the [ADBC Driver Foundry](https://adbc-drivers.org) for *Linux*,
*Mac*, & *Windows*, and can be installed for every language at once with
[dbc](https://docs.columnar.tech/dbc):

```
dbc install kinetica
```

Any language with an ADBC driver manager (*Go*, *R*, *C/C++*, *Java*, *DuckDB*,
*Polars*, etc.) then loads the driver by name, `kinetica`.  The driver can
also be loaded directly from its shared library:

* *Library*: `libadbc_driver_kinetica.so` (*Linux*),
  `libadbc_driver_kinetica.dylib` (*Mac*), or
  `adbc_driver_kinetica.dll` (*Windows*)
* *Entrypoint*: `AdbcDriverKineticaInit`

Release archives for each platform are available from the
[driver repository](https://github.com/adbc-drivers/kinetica) on *GitHub*, which also holds the driver's source.  The
[Foundry driver page](https://docs.adbc-drivers.org/drivers/kinetica) carries the Foundry's own reference for the driver.

### Rust

Rust applications can use the driver's native API directly, as a `git`
dependency on the [driver repository](https://github.com/adbc-drivers/kinetica):

```toml title="Dependency" theme={null}
[dependencies]
kinetica-adbc = { git = "https://github.com/adbc-drivers/kinetica", tag = "rust/v7.2.2" }
```

The crate's `driver_exporter` feature, on by default, also builds the C ABI
that the ADBC driver manager loads; Rust-only consumers can turn it off with
`--no-default-features`.

## Connecting

### ADBC Applications

A connection takes the URL of the *Kinetica* database server as its `uri`,
with a `username` & `password`.  Every other setting is an option named
`kinetica.<option>`; see [ADBC Configuration](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config).

To create a connection from *Python*, using the bundled driver:

```python HTTP theme={null}
import adbc_driver_kinetica.dbapi as kinetica

conn = kinetica.connect("http://<db.host>:9191", db_kwargs={
    "username": "<username>",
    "password": "<password>",
})
```

```python HTTPS w/o Cert Check theme={null}
import adbc_driver_kinetica.dbapi as kinetica

conn = kinetica.connect("https://<db.host>:8082/gpudb-0", db_kwargs={
    "username": "<username>",
    "password": "<password>",
    "kinetica.bypass_ssl_cert_check": "true",
})
```

```python HTTPS w/ Default Trust Cert Check theme={null}
import adbc_driver_kinetica.dbapi as kinetica

conn = kinetica.connect("https://<db.host>:8082/gpudb-0", db_kwargs={
    "username": "<username>",
    "password": "<password>",
})
```

```python HTTPS w/ Custom Trust Cert Check theme={null}
import adbc_driver_kinetica.dbapi as kinetica

conn = kinetica.connect("https://<db.host>:8082/gpudb-0", db_kwargs={
    "username": "<username>",
    "password": "<password>",
    "kinetica.trust_store_path": "<trustStorePath>",
    "kinetica.trust_store_password": "<trustStorePassword>",
})
```

```python HTTPS w/ OAuth Token theme={null}
import adbc_driver_kinetica.dbapi as kinetica

conn = kinetica.connect("https://<db.host>:8082/gpudb-0", db_kwargs={
    "kinetica.auth_method": "oauth",
    "kinetica.oauth_token": "<oauthToken>",
})
```

The connection returned is a standard ADBC one, so everything the
[ADBC Python documentation](https://arrow.apache.org/adbc/current/python/index.html) describes works with it.

To create a connection through the ADBC driver manager, after installing the
driver with [dbc](https://docs.columnar.tech/dbc) (this requires `adbc-driver-manager` 1.8 or later, which
finds a driver by name):

```python title="Driver Manager" theme={null}
from adbc_driver_manager import dbapi

conn = dbapi.connect(
    driver="kinetica",
    db_kwargs={
        "uri": "http://<db.host>:9191",
        "username": "<username>",
        "password": "<password>",
    },
)
```

To create a connection from *Rust*, using the driver's native API:

```rust title="Rust" theme={null}
use adbc_core::options::{OptionDatabase, OptionValue};
use adbc_core::sync::{Connection, Database, Driver, Statement};
use adbc_driver_kinetica::KineticaDriver;

let mut driver = KineticaDriver::default();
let database = driver.new_database_with_opts([
    (OptionDatabase::Uri, OptionValue::String("http://<db.host>:9191".into())),
    (OptionDatabase::Username, OptionValue::String("<username>".into())),
    (OptionDatabase::Password, OptionValue::String("<password>".into())),
])?;

let mut statement = database.new_connection()?.new_statement()?;
statement.set_sql_query("SELECT * FROM example.vehicle")?;

for batch in statement.execute()? {
    println!("{} rows", batch?.num_rows());
}
```

> [!NOTE]
>
> The driver must not be called from inside an asynchronous *Tokio*
> context; a Rust application running under *Tokio* calls it from a
> blocking task.

### Connection URI

The `uri` may also be a `kinetica://` URI, by which a driver manager given
only the URI knows to load this driver.  The URI connects over HTTPS unless it
says `tls=false`, and every other query parameter is a driver option under
its own name; an option set directly takes precedence over the URI's.

```text Syntax theme={null}
kinetica://[<username>[:<password>]@]<db.host>[:<db.port>][/<path>][?<parameter>=<value>[&<parameter>=<value>]*]
```

```text Example theme={null}
kinetica://kineticahost:9191?tls=false
```

```text Example w/ Option theme={null}
kinetica://kineticahost:8082/gpudb-0?kinetica.query.max_rows=1000
```

```python title="Connection URI" theme={null}
conn = kinetica.connect(
    "kinetica://localhost:9191?tls=false",
    db_kwargs={"username": "<username>", "password": "<password>"},
)
```

#### Secure Connections

When connecting to a *Kinetica* instance over HTTPS, the `uri` should
reference the database's secure address, and the driver validates the server's
certificate against the system's trusted certificates.

> [!TIP]
>
> See [Connection Options](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-connection) for additional parameters
> that may be necessary to use when connecting over SSL.

To validate against a custom trust store instead, set
`kinetica.trust_store_path` (and `kinetica.trust_store_password`, if the
store has one).  To accept the server's certificate without checking it, set
`kinetica.bypass_ssl_cert_check` to `true`; prefer a trust store wherever
the certificate can be trusted.

#### Failover Connections

When connecting to a *Kinetica* instance with one or more failover clusters, the
`uri` should be updated to contain a comma-delimited list of *head node*
addresses for all clusters.  The URL of the primary cluster can also be
specified.

List all cluster *head node* addresses in the `uri` and add a
`kinetica.primary_url` option designating the cluster that should be tried
first.

```text Syntax theme={null}
kinetica://<database1.host>:<database1.port>,...,<databaseN.host>:<databaseN.port>?tls=false&kinetica.primary_url=http://<databaseX.host>:<databaseX.port>
```

```text Example theme={null}
kinetica://kineticaA:9191,kineticaB:9191,kineticaC:9191?tls=false&kinetica.primary_url=http://kineticaB:9191
```

By default, the driver discovers the rest of the HA ring from the first cluster
it reaches, fails over to another cluster when one fails, and returns to the
primary once it is reachable again.  See [Connection Options](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-connection)
for the options governing each.

### Other ADBC Clients

Any tool that loads ADBC drivers can use the *Kinetica* driver, once it is
installed with [dbc](https://docs.columnar.tech/dbc) or the shared library is placed where the tool can find
it.  The following is the general driver and connection information that should
be used when configuring a client.

* *Driver*: `kinetica`, or the path to the downloaded shared library
* *Entrypoint*: `AdbcDriverKineticaInit`
* *Connection URI*:

```text Syntax theme={null}
kinetica://[<username>[:<password>]@]<db.host>[:<db.port>][/<path>][?<parameter>=<value>[&<parameter>=<value>]*]
```

```text Example theme={null}
kinetica://kineticahost:9191?tls=false
```

See [ADBC Configuration](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config) for additional configuration parameters.

## Using the Driver

The following examples use the *Python* package; the same operations are
available through every ADBC driver manager.

### Querying Data

A cursor executes any *Kinetica* SQL and returns the result as Arrow.  Rows can
be fetched one at a time, but for a large result, take the Arrow table or data
frame directly:

```python title="Query" theme={null}
cur = conn.cursor()

cur.execute("SELECT * FROM example.vehicle")

rows = cur.fetchall()               # list of tuples
table = cur.fetch_arrow_table()     # pyarrow.Table
frame = cur.fetch_df()              # pandas.DataFrame, needs [dataframe]
```

Parameters use `?` placeholders and are bound as Arrow values:

```python title="Parameters" theme={null}
cur.execute("SELECT * FROM example.vehicle WHERE id = ?", (42,))
```

A query bound to several rows of parameters runs once for each row, and the
results are returned as one stream.

A large result is paged from a server-side result table, so every page reads
one consistent snapshot of a single execution.  `kinetica.query.batch_size`
sets the rows requested per page and `kinetica.query.max_rows` caps the rows
returned; see [Query Options](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-query).

> [!NOTE]
>
> After `execute()` of an `INSERT`, `UPDATE`, or `DELETE`, the
> cursor's `rowcount` is `-1`, as the driver cannot return a count
> alongside a result stream; `executemany()` reports it correctly.
> The count is also available from the statement as
> `kinetica.count_affected`; see [Statement Results](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-results).

### Loading Data

Data can be inserted with SQL, as with any other client:

```python title="Insert" theme={null}
cur.execute("CREATE TABLE example.vehicle (id INTEGER, make VARCHAR(32), model VARCHAR(64))")
cur.execute("INSERT INTO example.vehicle VALUES (1, 'Cord', '812'), (2, 'Bugatti', 'La Voiture Noire')")
```

For anything more than a few rows, hand over an Arrow table and let the driver
route it to the worker ranks, using
[distributed ingest](https://docs.kinetica.com/content/tuning/multihead/multihead_ingest.md):

```python title="Bulk Load" theme={null}
import pyarrow as pa

batch = pa.table({
    "id": [3, 4],
    "make": ["Duesenberg", "Tucker"],
    "model": ["Model J", "48"],
})
cur.adbc_ingest("example.vehicle", batch, mode="append")
```

The `mode` is one of:

* `append` = Add the rows to an existing table
* `create` = Create the table from the Arrow schema, failing if it exists
* `create_append` = Create the table if it does not exist, then add the rows
* `replace` = Drop any existing table and create it from the Arrow schema

A plain `INSERT INTO ... VALUES (?, ...)` with bound rows also goes directly
to the worker ranks; an `INSERT` with expressions, a `SELECT` source, or an
`ON CONFLICT` clause is executed by the server.

A local file can be loaded with
[INSERT INTO ... SELECT ... FROM FILE](https://docs.kinetica.com/content/sql/load/insert-into-select-from-file.md#sql-load-file-client),
which the driver reads on the client and sends to the worker ranks; the file
options are listed under [Ingest Options](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-ingest):

```python title="Load File" theme={null}
cur.execute('INSERT INTO example.vehicle SELECT * FROM FILE."vehicles.csv"')
```

> [!NOTE]
>
> A load is not transactional:  when a load fails part-way, the rows
> already sent remain in the table, and the error reports how many
> rows were loaded.

### Reading the Catalog

The standard ADBC metadata calls return the catalog as Arrow, including primary
& foreign keys, with the table & columns each foreign key points at:

```python title="Catalog" theme={null}
conn.adbc_get_table_schema("example.vehicle")   # pyarrow.Schema
conn.adbc_get_objects(depth="tables").read_all()
```

Filters are `LIKE` patterns.  *Kinetica* has a single, unnamed catalog.

### Transactions

*Kinetica* has no multi-statement transactions.  Autocommit is always on, and a
statement has taken effect by the time it returns.  By default, `commit()` &
`rollback()` are refused, and the *Python* driver manager warns once:

```
Warning: Cannot disable autocommit; conn will not be DB-API 2.0 compliant
```

The connection works normally after the warning.  A tool that insists on
calling them can have them accepted and ignored instead, by setting
`kinetica.fake_transactions` to `true`.

### Sessions & Temp Tables

A connection is a server session, and the
[session temp tables](https://docs.kinetica.com/content/sql/ddl/session-temp-tables.md#sql-session-temp-tables) it creates belong
to that session alone; closing the connection drops them.

```python title="Temp Table" theme={null}
cur.execute("CREATE TABLE #work (a INT)")
cur.execute("INSERT INTO #work VALUES (1)")
...
conn.close()                 # #work goes with the session
```

To share temp tables among connections, set `kinetica.session_id` on each to
the same ID; every connection given the same ID sees the same tables.  A
session named this way is left in place when a connection closes, for its owner
to drop.

The SQL session statements [SET USER](https://docs.kinetica.com/content/sql/security/set-user.md#sql-security-impersonation-setuser),
[EXECUTE AS USER](https://docs.kinetica.com/content/sql/security/execute-as.md#sql-security-impersonation-exec-as),
[REVERT](https://docs.kinetica.com/content/sql/security/revert.md#sql-security-impersonation-revert),
`SET SCHEMA`, & [SET CATALOG](https://docs.kinetica.com/content/sql/ddl/set-catalog.md#sql-set-catalog) are also
available, for tools that can only send SQL.

## Data Types

The Arrow type of each result column is chosen by the server, so a table read
through the driver and written back arrives as it left.  Every result column
also carries the *Kinetica* type as its SQL writes it (e.g., `VARCHAR(16)` or
`DECIMAL(10,2)`) under the field metadata key `KINETICA:type`, with the
column's properties & nullability under `KINETICA:properties` &
`KINETICA:nullable`.

| Category | Kinetica Data Type | Arrow Type | Notes |
| - | - | - | - |
| Number | `BOOLEAN` | `boolean` | |
| | `TINYINT` | `int8` | |
| | `SMALLINT` | `int16` | |
| | `INTEGER` | `int32` | |
| | `BIGINT` | `int64` | |
| | `UNSIGNED BIGINT` | `uint64` | |
| | `REAL` | `float32` | |
| | `DOUBLE` | `float64` | |
| | `DECIMAL(P,S)` | `decimal128(P,S)` | |
| String | `VARCHAR` | `utf8` | `VARCHAR(N)` as well; the width is in `KINETICA:type` |
| | `IPV4` | `utf8` | Dotted-quad text |
| | `UUID` | `fixed_size_binary(16)` | Extension type `arrow.uuid` |
| | `JSON` | `utf8` | Extension type `arrow.json` |
| Date/Time | `DATE` | `date32` | |
| | `TIME` | `time32[ms]` | |
| | `DATETIME` | `timestamp[ms]` | A wall-clock time, so it carries no time zone |
| | `TIMESTAMP` | `timestamp[ms, UTC]` | An instant, so it carries the `UTC` zone; the zone is what tells it from a `DATETIME` |
| Binary | `BLOB` | `binary` | |
| Geospatial | `GEOMETRY` | `binary` | Extension type `geoarrow.wkb`; the server sends WKB whatever the column is declared as, and a load accepts WKB or WKT |
| Composite | `VECTOR(N)` | `fixed_size_list<float32>[N]` | |
| | `BOOLEAN[N]`, `INTEGER[N]`, etc. | `utf8` | The JSON text of the array |

When loading data, the mapping runs in reverse:  an Arrow `timestamp` of any
unit is stored as milliseconds; a `timestamp` with a time zone becomes a
`TIMESTAMP` and one without becomes a `DATETIME`; `decimal256` is stored
as `DECIMAL`; and the extension types above map back to their *Kinetica*
types.  A table the driver creates from an Arrow schema uses the same mapping
for its [column types](https://docs.kinetica.com/content/sql/ddl/column-types.md#sql-column-types).

## ADBC Configuration

Configuration parameters are passed as options when the database handle is
created (`db_kwargs` in *Python*), or as query parameters of a
`kinetica://` [connection URI](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-uri); an option set
directly takes precedence over the URI's.  A boolean option takes `true` or
`false`.  Each option is set on the database unless noted otherwise; an
option set on the database is inherited by its connections.

Some settings of note follow.

### Connection Options

| Config Parameter | Default Value | Description |
| - | - | - |
| `uri` | | URL of the *Kinetica* database server to connect to, or a `kinetica://` [connection URI](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-uri); either may list several comma-delimited cluster addresses in an HA configuration   Required.  Standard ADBC option. |
| `username` | | User ID for database connection.  Standard ADBC option. |
| `password` | | Password for database connection.  Standard ADBC option. |
| `adbc.connection.db_schema` | *\<user default>* | Default schema to use within the session; a schema that does not exist is refused when set.  Standard ADBC option. |
| `adbc.connection.catalog` | | Default catalog to use within the session.  Standard ADBC option. |
| `kinetica.session_id` | *\<new for each* *connection>* | ID of an existing server session to join, so this connection shares its [session temp tables](https://docs.kinetica.com/content/sql/ddl/session-temp-tables.md#sql-session-temp-tables).  A session named here is left in place when the connection closes, for its owner to drop. |
| `kinetica.impersonate_user` | | Impersonate another user for this session.  Only available when connected as an admin. |
| `kinetica.fake_transactions` | `false` | Whether to accept transaction calls, such as turning autocommit off, and do nothing, rather than refuse them   \* `false` = Refuse transaction calls  \* `true` = Accept transaction calls and do nothing  \[!NOTE] *Kinetica* has no transactions, so a rollback undoes nothing either way; this setting only decides whether the caller is told. |
| `kinetica.replication` | *\<server default>* | How far a write must have replicated across an HA ring before the server responds; one of `sync`, `sync_parallel`, `async`, `async_parallel`, or `none` |
| `kinetica.no_sync` | `false` | Shorthand for a `kinetica.replication` of `none`; `kinetica.replication` takes precedence when both are given |
| `kinetica.primary_url` | *\<first address* *of the URI>* | URL of the cluster to always attempt to go to first, and that failover returns to once it is reachable again (if `uri` is a list) |
| `kinetica.failover` | `true` | Whether or not to fail over to another cluster of the HA ring when the current one fails |
| `kinetica.failover_order` | `sequential` | Order in which the clusters of the ring are tried when one fails; one of `sequential` or `random` |
| `kinetica.auto_discovery` | `true` | Whether or not to discover the rest of the HA ring from the first cluster reached; when `false`, only the addresses given in `uri` are used |
| `kinetica.failback_poll_interval` | *\<Rust API default>* | Seconds between polls of the primary cluster, by which a connection that failed away from it returns |
| `kinetica.hostname_regex` | | Regular expression selecting which of a worker's addresses to use, where a worker publishes more than one; bulk loads go to the addresses it keeps |
| `kinetica.request_timeout` | *\<Rust API default>* | Seconds to wait for a response from the database; `0` for no timeout |
| `kinetica.connect_timeout` | *\<Rust API default>* | Seconds to wait for the server to answer a connection attempt |
| `kinetica.initial_connect_timeout` | *\<Rust API default>* | Seconds to spend reaching a cluster for the first time before trying the next |
| `kinetica.max_retries` | *\<Rust API default>* | Number of times a request is re-sent, when it failed on the wire or was refused by a cluster still starting up after coming back online |
| `kinetica.snappy` | `true` | Whether or not to compress bulk record requests with *Snappy* |
| `kinetica.log_level` | `off` | Amount the driver logs; one of `off`, `error`, `warn`, `info`, `debug`, or `trace`.  See [Logging](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-logging). |
| `kinetica.log_path` | | File the driver log is appended to; when empty, the log is written to standard error |

### Authentication Options

Password authentication is the default.  For OAuth, either hand over a token
the caller acquired itself, or name a grant and let the driver acquire one.
See [HTTPS Connections with OIDC/OAuth Authentication](https://docs.kinetica.com/content/api/concepts.md#https-with-oauth)
for the server-side setup.

| Config Parameter | Default Value | Description |
| - | - | - |
| `kinetica.auth_method` | `password` | How the connection authenticates   \* `password` = Authenticate with `username` & `password`  \* `oauth` = Authenticate with an OAuth bearer token |
| `kinetica.oauth_token` | | OAuth token used in OIDC-enabled environments, presented as given; the driver does not acquire one.  When using, leave `username` & `password` blank. |
| `kinetica.oauth_grant` | | OAuth grant by which the driver acquires a bearer token, when the caller does not hold one; one of `client_credentials`, `authorization_code`, `device_code`, `refresh_token`, `token-exchange`, or `jwt-bearer`.  Each grant's RFC URN is accepted as well.  \[!NOTE] `authorization_code` opens a browser and `device_code` prints a URL and a code; both need someone present, so neither suits a connection pool. |
| `kinetica.auth_provider` | | Identity provider whose own parameters the driver translates into the generic OAuth ones: `entra` or `okta`; or `command`, which runs the `kinetica.oauth.command` command line and takes what it prints as the token.   `entra` and `okta` are each implied by a parameter only they read, so naming one is an override rather than a requirement.  \[!NOTE] The `command` runs under `sh -c` (`cmd.exe /c` on *Windows*) with the privileges of the process holding the connection, so it must never come from untrusted input. |
| `kinetica.oauth.<name>` | | Parameters of the OAuth flow: `issuer`, `token_url`, `authorize_url`, `device_url`, `client_id`, `client_secret`, `scope`, `audience`, `subject`, `refresh_token`, `subject_token`, `subject_token_type`, `private_key`, `private_key_file`, `key_id`, & `algorithm`.  Given an `issuer` alone, the endpoints are read from its OpenID Connect discovery document.   Provider parameters are named the same way: `tenant_id`, `application_id_uri` (or `resource`), & `authority_host` for `entra`; `okta_domain` & `auth_server_id` for `okta`; `command` & `command_timeout_seconds` for `command`. |
| `kinetica.token_name_claim` | `sub` | Name of the claim in the bearer token identifying the username; `preferred_username` under `entra`.  The name a token gives takes precedence over `username`. |
| `kinetica.oauth_token_cache` | `memory` | Whether acquired tokens are shared   \* `memory` = Share one token among every connection of the process that would ask for the same one  \* `none` = Sign in for each connection |

An acquired token is held for the process and renewed before it expires;
concurrent connections wanting the same token sign in once between them.  The
token is settled when the connection is opened and not revisited, so a
connection held open longer than its token's lifetime will start failing; open
a new one rather than expecting it to recover.

```python title="Client Credentials" theme={null}
conn = kinetica.connect("http://<db.host>:9191", db_kwargs={
    "kinetica.auth_method": "oauth",
    "kinetica.oauth_grant": "client_credentials",
    "kinetica.oauth.issuer": "https://id.example/realms/kinetica",
    "kinetica.oauth.client_id": "analytics",
    "kinetica.oauth.client_secret": "<clientSecret>",
})
```

### Query Options

| Config Parameter | Default Value | Description |
| - | - | - |
| `kinetica.query.batch_size` | `20000` | Rows requested from the server per page of a result, capped at the server's own limit.  Set on a statement. |
| `kinetica.query.max_rows` | *\<all rows>* | Maximum rows a read returns, however many the result holds; unset or negative returns all of them.  Set on the database, a connection, or a statement; the statement's own wins. |
| `kinetica.query.use_key_lookup` | `false` | Whether or not a `SELECT` that pins every key column of a table may be answered by the rank holding the row, bypassing the SQL engine.  See [Distributed Key Lookup](https://docs.kinetica.com/content/tuning/multihead/multihead_egress.md). Set on the database, a connection, or a statement; the statement's own wins. |
| `kinetica.query.paging_table_ttl` | `20` | Minutes the server keeps the result a paged read works through.  The driver clears it as soon as the read is done, so this only matters for a read left unfinished. |

The following are optional parameters that could be used to override the
default settings, which are set by the server.  See the
[Configuration Reference](https://docs.kinetica.com/content/config.md#config-main-sql-engine) for more
information on configuring the SQL Engine server-side.  Each is sent with
every statement, but only when set, so an unset one leaves the server's own
default in place.  Each can be set on the database or a connection.

| Config Parameter | Description |
| - | - |
| `kinetica.query.cost_based_optimization` | Whether or not to use the cost-based optimizer |
| `kinetica.query.rule_based_optimization` | Whether or not to use the rule-based optimizer |
| `kinetica.query.ssq_optimization` | Whether or not to optimize scalar subqueries |
| `kinetica.query.distributed_operations` | Whether or not to process operations that would require resharding of data to complete successfully; when `false`, such a query fails |
| `kinetica.query.parallel_execution` | Whether or not to execute independent portions of a query in parallel |
| `kinetica.query.plan_cache` | Whether or not to cache query plans, as derived by the rule-based/cost-based optimizer |
| `kinetica.query.results_caching` | Whether or not to cache result sets, which happens automatically for certain queries that have only [materialized views](https://docs.kinetica.com/content/concepts/materialized_views.md) as sources |
| `kinetica.query.ignore_existing_pk` | Whether or not to suppress errors for record collisions when inserting into or updating a table with a primary key; ignored if the table has no primary key or `kinetica.query.update_on_existing_pk` is `true` |
| `kinetica.query.update_on_existing_pk` | Whether or not to handle primary key collisions using an *upsert* scheme for inserts and overwrite scheme for updates when operating on a table with a primary key; ignored if the table has no primary key |
| `kinetica.query.validate_change_column` | Whether or not to validate a column's existing data when changing its type |
| `kinetica.query.use_approx_count_distinct` | Whether or not `COUNT(DISTINCT ...)` may be computed approximately |
| `kinetica.query.ttl` | [TTL](https://docs.kinetica.com/content/concepts/ttl.md) for temporary result tables, in minutes |

### Ingest Options

The following govern bulk loads via `adbc_ingest`, a bound
`INSERT INTO ... VALUES`, and `INSERT INTO ... SELECT ... FROM FILE`.  Each
can be set on the database or a connection.

| Config Parameter | Default Value | Description |
| - | - | - |
| `kinetica.ingest.multihead_insert` | `true` | Whether or not rows are sent directly to the worker ranks that hold them; when `false`, they go through the head rank.  See [Distributed Ingest](https://docs.kinetica.com/content/tuning/multihead/multihead_ingest.md). |
| `kinetica.ingest.rows_per_insertion` | `50000` | Rows sent to a worker at a time |
| `kinetica.ingest.error_mode` | `abort` | What to do about a row the workers cannot take   \* `abort` = Fail the batch holding the row  \* `skip` = Load the rest of the batch without the row  \* `permissive` = Load the rest of the batch and ask the server what was wrong with each row it refused |
| `kinetica.ingest.truncate_strings` | `false` | Whether or not to truncate a string too long for its column, rather than refusing it |

The following options read a local file loaded by
`INSERT INTO ... SELECT ... FROM FILE`.  A statement can also give each in
its own `WITH OPTIONS (...)` clause, as `file read` followed by the
option's last part (e.g., `file read limit = 100`), which takes precedence
over the connection's.

| Config Parameter | Default Value | Description |
| - | - | - |
| `kinetica.ingest.file.delimiter` | *\<by extension>* | Field separator; unset, it is `\|` for `.psv`, a tab for `.tsv`, and otherwise a comma.  A tab may be written `\t`. |
| `kinetica.ingest.file.quote_char` | `"` | Quote character |
| `kinetica.ingest.file.escape_char` | | Escape character; unset, a quote is escaped by doubling it |
| `kinetica.ingest.file.comment_char` | | Lines starting with this character are skipped |
| `kinetica.ingest.file.has_header` | `true` | Whether or not the first line names the columns |
| `kinetica.ingest.file.null_string` | | Text that stands for a null; unset, an empty field is null |
| `kinetica.ingest.file.skip` | `0` | Rows to skip at the start of each file, after its header |
| `kinetica.ingest.file.limit` | *\<all rows>* | Maximum rows to read across every file matched |
| `kinetica.ingest.file.initial_clear` | `false` | Whether or not to empty the table before loading the file into it |

### Statement Results

The following are read from a statement after it runs (`get_option_int` on
the statement, or the `adbc_statement` of a *Python* cursor), as the ADBC
interface has no room for them on a call that also returns a reader.

> [accordion] kinetica.count\_affected
>
> Rows the last statement changed, or `-1` if it was a query

> [accordion] kinetica.total\_number\_of\_records
>
> Rows the last statement's whole result holds, however many have been read so far, or `-1` if it produced no result.
> A query bound to several rows of parameters runs once for each, and this adds up the runs made so far.  Also available
> as the standard `adbc.statement.exec.max_progress` option.

> [accordion] kinetica.key\_lookup
>
> `1` if the last read was answered by the rank holding its row, `0` if it went through the SQL engine

## Logging

The driver logs through the `kinetica.log_level` & `kinetica.log_path`
options; see [Connection Options](https://docs.kinetica.com/content/connectors/adbc_guide.md#adbc-config-connection).  A host program that has
installed a logger of its own keeps it.

*Kinetica* logs inbound SQL requests, internal calls made on behalf of those
requests, and other debugging information.  These logs can be found in the
following log files:

* /opt/gpudb/core/logs/host-manager-\<hostname>-\<datetime>.log:  Contains
  all endpoint calls, including the initial call to `/execute/sql` and any
  endpoint calls made as a result of servicing the request
* /opt/gpudb/sql/logs/sql-engine-\<kinetica-hostname>.log:  Contains
  detailed error messages


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.