Skip to main content
pub struct SqlResult  /* private fields */ 

Wrapper around RawExecuteSqlResponse with convenient parsing methods.

SqlResult provides ergonomic access to query results including:

  • Row iteration
  • Column extraction
  • Scalar value retrieval
  • Direct deserialization to structs

Example

Implementations

Source

pub fn new(response: RawExecuteSqlResponse) -> Self

Create a new SqlResult from an RawExecuteSqlResponse

Source

pub fn with_column_names( response: RawExecuteSqlResponse, column_names: &[&str], ) -> Self

Create a SqlResult with column name mapping

The column_names slice should contain the column names in order, which will be mapped to column_1, column_2, etc.

Get the underlying RawExecuteSqlResponse

Consume and return the underlying RawExecuteSqlResponse

Source

pub fn total_records(&self) -> i64

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

Source

pub fn count_affected(&self) -> i64

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

Source

pub fn has_more(&self) -> bool

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

Source

pub fn paging_table(&self) -> Option<&str>

Get the paging table name (if any)

Source

pub fn info(&self) -> &HashMap<String, String>

Get info metadata from the response

Source

pub fn json_response(&self) -> &str

Get the raw JSON response string

Source

pub fn row_count(&mut self) -> SqlOpResult<usize>

Get the number of rows in the result

Get all column names in the result

Returns the raw column names (column_1, column_2, etc.) unless column mapping was provided via with_column_names.

Source

pub fn column<T: DeserializeOwned>(&mut self, name: &str) -> SqlOpResult<Vec<T>>

Extract a single column as a Vec

Source

pub fn scalar<T: DeserializeOwned>(&mut self) -> SqlOpResult<T>

Get a single scalar value from the first row, first column

Useful for queries like SELECT COUNT(*) FROM table

Source

pub fn get<T: DeserializeOwned>( &mut self, row: usize, column: &str, ) -> SqlOpResult<T>

Get a value from a specific row and column

Source

pub fn rows(&mut self) -> SqlOpResult<Vec<Row>>

Iterate over rows in the result

Deserialize all rows into a Vec of structs

Trait Implementations

Source

fn fmt(&self, f: &mut Formatter<’_>) -> Result

Formats the value using the given formatter. Read more