> ## 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.

# sql

> sql — Kinetica Rust API

[gpudb\_api](https://docs.kinetica.com/content/api/rust/index.md)
[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L1-L2335)&#x20;

SQL client and result parser for Kinetica’s HTTP APIStatements are sent to `/execute/sql` over the same [`Kinetica`](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica) connection used by the rest of the API, so they share its authentication, TLS and HA failover. For the PostgreSQL wire protocol, see the `sqlx_support` module (feature `sqlx`).

## Overview

<ul>
  <li>**[`SqlClient`](https://docs.kinetica.com/content/api/rust/sql/struct.SqlClient)** - Executes SQL, with paging support for large result sets</li>
  <li>**[`SqlResult`](https://docs.kinetica.com/content/api/rust/sql/struct.SqlResult)** / **[`Row`](https://docs.kinetica.com/content/api/rust/sql/struct.Row)** - Wrap `RawExecuteSqlResponse` with convenient parsing methods</li>
  <li>**[`SqlHints`](https://docs.kinetica.com/content/api/rust/sql/struct.SqlHints)** - Kinetica-specific execution options and inline hints</li>
  <li>**[`BatchingSqlClient`](https://docs.kinetica.com/content/api/rust/sql/struct.BatchingSqlClient)** - Routes `INSERT` statements through `BulkInserter`</li>
</ul>

## Quick Start

```rust theme={null}
use gpudb_api::{Kinetica, KineticaOptions, SqlClient};
use std::sync::Arc;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let options = KineticaOptions::new();
    let kinetica = Arc::new(
        Kinetica::new(vec!["http://localhost:9191".to_string()], options).await?
    );

    let client = SqlClient::new(kinetica);
    let mut result = client
        .execute("SELECT id, name FROM my_table WHERE value > 100 ORDER BY id LIMIT 10")
        .await?;

    for row in result.rows()? {
        let id: i64 = row.get("id")?;
        let name: String = row.get("name")?;
        println!("id={}, name={}", id, name);
    }

    Ok(())
}
```

## Result Parsing

```rust theme={null}
use gpudb_api::SqlResult;

// Get total count
let total = result.total_records();

// Check if there are more records
if result.has_more() {
    println!("More records available");
}

// Get a single scalar value
let count: i64 = result.scalar()?;

// Get a column as a vector
let names: Vec<String> = result.column("name")?;

// Iterate over rows
for row in result.rows()? {
    let id: i64 = row.get("id")?;
    let name: String = row.get("name")?;
    // Process row...
}

// Deserialize into structs
#[derive(serde::Deserialize)]
struct User { id: i64, name: String }
let users: Vec<User> = result.deserialize()?;
```

## Re-exports

`pub use crate::sql_insert_parser::parse_insert_statement;``pub use crate::sql_insert_parser::parse_sql_value_to_record_value;``pub use crate::sql_insert_parser::ParsedInsert;`

## Structs

[Batching<wbr />SqlClient](https://docs.kinetica.com/content/api/rust/sql/struct.BatchingSqlClient.md)A SQL client that automatically batches INSERT statements for high-performance bulk loading.[Batching<wbr />Stats](https://docs.kinetica.com/content/api/rust/sql/struct.BatchingStats.md)Statistics from batched SQL execution[Pagination<wbr />Stats](https://docs.kinetica.com/content/api/rust/sql/struct.PaginationStats.md)Statistics from a paginated query execution[Row](https://docs.kinetica.com/content/api/rust/sql/struct.Row.md)A single row from a SQL result set.[SqlClient](https://docs.kinetica.com/content/api/rust/sql/struct.SqlClient.md)High-level SQL client that wraps Kinetica with result parsing.[SqlHints](https://docs.kinetica.com/content/api/rust/sql/struct.SqlHints.md)SQL hints that can be embedded in statements or passed as execute\_sql options.[SqlResult](https://docs.kinetica.com/content/api/rust/sql/struct.SqlResult.md)Wrapper around `RawExecuteSqlResponse` with convenient parsing methods.

## Enums

[SqlError](https://docs.kinetica.com/content/api/rust/sql/enum.SqlError.md)Error type for SQL operations

## Type Aliases

[SqlOp<wbr />Result](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)Type alias for SQL operation results


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