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

# SqlResult

> SqlResult — Kinetica Rust API

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

<pre>`pub struct SqlResult { /* private fields */ }`</pre>

Wrapper around `RawExecuteSqlResponse` with convenient parsing methods.`SqlResult` provides ergonomic access to query results including:

<ul>
  <li>Row iteration</li>
  <li>Column extraction</li>
  <li>Scalar value retrieval</li>
  <li>Direct deserialization to structs</li>
</ul>

## Example

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

// Check metadata
println!("Total records: {}", result.total_records());
println!("Has more: {}", result.has_more());

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

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

// Iterate rows
for row in result.rows()? {
    let id: i64 = row.get("id")?;
    println!("ID: {}", id);
}
```

## Implementations

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L803-L1095)
impl [SqlResult](https://docs.kinetica.com/content/api/rust/sql/struct.SqlResult.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L805-L811)
pub fn [new](#method.new)(response: [RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md)) -> Self

Create a new SqlResult from an RawExecuteSqlResponse

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L817-L827)
pub fn [with\_column\_names](#method.with_column_names)( response: [RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md), column\_names: &\[&[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html)], ) -> Self

Create a SqlResult with column name mappingThe column\_names slice should contain the column names in order, which will be mapped to column\_1, column\_2, etc.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L830-L832)
pub fn [inner](#method.inner)(\&self) -> &[RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md)

Get the underlying RawExecuteSqlResponse

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L835-L837)
pub fn [into\_inner](#method.into_inner)(self) -> [RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md)

Consume and return the underlying RawExecuteSqlResponse

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L840-L842)
pub fn [total\_records](#method.total_records)(\&self) -> [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html)

Get the total number of records matching the query (before LIMIT)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L845-L847)
pub fn [count\_affected](#method.count_affected)(\&self) -> [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html)

Get the number of records affected by the query (INSERT/UPDATE/DELETE)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L850-L852)
pub fn [has\_more](#method.has_more)(\&self) -> [bool](https://doc.rust-lang.org/1.98.1/std/primitive.bool.html)

Check if there are more records available (for paginated queries)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L855-L861)
pub fn [paging\_table](#method.paging_table)(\&self) -> [Option](https://doc.rust-lang.org/1.98.1/core/option/enum.Option.html)\<&[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html)>

Get the paging table name (if any)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L864-L866)
pub fn [info](#method.info)(\&self) -> &[HashMap](https://doc.rust-lang.org/1.98.1/std/collections/hash/map/struct.HashMap.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>

Get info metadata from the response

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L869-L871)
pub fn [json\_response](#method.json_response)(\&self) -> &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html)

Get the raw JSON response string

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L898-L908)
pub fn [row\_count](#method.row_count)(\&mut self) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<[usize](https://doc.rust-lang.org/1.98.1/std/primitive.usize.html)>

Get the number of rows in the result

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L914-L926)
pub fn [column\_names](#method.column_names)(\&mut self) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<[Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html)>>

Get all column names in the resultReturns the raw column names (column\_1, column\_2, etc.) unless column mapping was provided via `with_column_names`.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L941-L958)
pub fn [column](#method.column)\<T: [DeserializeOwned](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html)>(\&mut self, name: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html)) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<[Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<T>>

Extract a single column as a Vec

##### Example

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

let ids: Vec<i64> = result.column("column_1")?;
let names: Vec<String> = result.column("column_2")?;
```

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L974-L988)
pub fn [scalar](#method.scalar)\<T: [DeserializeOwned](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html)>(\&mut self) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<T>

Get a single scalar value from the first row, first columnUseful for queries like `SELECT COUNT(*) FROM table`

##### Example

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

let count: i64 = result.scalar()?;
```

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L991-L1009)
pub fn [get](#method.get)\<T: [DeserializeOwned](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html)>( \&mut self, row: [usize](https://doc.rust-lang.org/1.98.1/std/primitive.usize.html), column: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), ) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<T>

Get a value from a specific row and column

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L1027-L1050)
pub fn [rows](#method.rows)(\&mut self) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<[Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[Row](https://docs.kinetica.com/content/api/rust/sql/struct.Row.md)>>

Iterate over rows in the result

##### Example

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

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

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L1074-L1083)
pub fn [deserialize](#method.deserialize)\<T: [DeserializeOwned](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html)>(\&mut self) -> [SqlOpResult](https://docs.kinetica.com/content/api/rust/sql/type.SqlOpResult.md)\<[Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<T>>

Deserialize all rows into a Vec of structs

##### Example

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

#[derive(Deserialize)]
struct User {
    column_1: i64,  // id
    column_2: String,  // name
}

let users: Vec<User> = result.deserialize()?;
for user in users {
    println!("id={}, name={}", user.column_1, user.column_2);
}
```

## Trait Implementations

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L794)
impl [Debug](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html) for [SqlResult](https://docs.kinetica.com/content/api/rust/sql/struct.SqlResult.md)

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/sql.rs#L794)
fn [fmt](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html#tymethod.fmt)(\&self, f: \&mut [Formatter](https://doc.rust-lang.org/1.98.1/core/fmt/struct.Formatter.html)\<'\_>) -> [Result](https://doc.rust-lang.org/1.98.1/core/fmt/type.Result.html)

Formats the value using the given formatter. [Read more](https://doc.rust-lang.org/1.98.1/core/fmt/trait.Debug.html#tymethod.fmt)


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