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
pub fn new(response: RawExecuteSqlResponse) -> Self
Create a new SqlResult from an RawExecuteSqlResponse
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.
pub fn inner(&self) -> &RawExecuteSqlResponse
Get the underlying RawExecuteSqlResponse
pub fn into_inner(self) -> RawExecuteSqlResponse
Consume and return the underlying RawExecuteSqlResponse
pub fn total_records(&self) -> i64
Get the total number of records matching the query (before LIMIT)
pub fn count_affected(&self) -> i64
Get the number of records affected by the query (INSERT/UPDATE/DELETE)
Check if there are more records available (for paginated queries)
pub fn paging_table(&self) -> Option<&str>
Get the paging table name (if any)
pub fn json_response(&self) -> &str
Get the raw JSON response string
pub fn row_count(&mut self) -> SqlOpResult<usize>
Get the number of rows in the result
pub fn column_names(&mut self) -> SqlOpResult<Vec<String>>
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.
pub fn column<T: DeserializeOwned>(&mut self, name: &str) -> SqlOpResult<Vec<T>>
Extract a single column as a Vec
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
pub fn get<T: DeserializeOwned>( &mut self, row: usize, column: &str, ) -> SqlOpResult<T>
Get a value from a specific row and column
pub fn deserialize<T: DeserializeOwned>(&mut self) -> SqlOpResult<Vec<T>>
Deserialize all rows into a Vec of structs