Struct rusqlite::Row
[−]
[src]
pub struct Row<'stmt> { // some fields omitted }
A single result row of a query.
Methods
impl<'stmt> Row<'stmt>
fn get<T: FromSql>(&self, idx: c_int) -> T
Get the value of a particular column of the result row.
Note that Row
can panic at runtime if you use it incorrectly. When you are
retrieving the rows of a query, a row becomes stale once you have requested the next row,
and the values can no longer be retrieved. In general (when using looping over the rows,
for example) this isn't an issue, but it means you cannot do something like this:
fn bad_function_will_panic(conn: &Connection) -> Result<i64> { let mut stmt = try!(conn.prepare("SELECT id FROM my_table")); let mut rows = try!(stmt.query(&[])); let row0 = try!(rows.next().unwrap()); // row 0 is value now... let row1 = try!(rows.next().unwrap()); // row 0 is now STALE, and row 1 is valid let my_id = row0.get(0); // WILL PANIC because row 0 is stale Ok(my_id) }
Failure
Panics if idx
is outside the range of columns in the returned query or if this row
is stale.
fn get_checked<T: FromSql>(&self, idx: c_int) -> Result<T>
Get the value of a particular column of the result row.
Failure
Returns a SQLITE_MISMATCH
-coded Error
if the underlying SQLite column
type is not a valid type as a source for T
.
Returns a SQLITE_MISUSE
-coded Error
if idx
is outside the valid column range
for this row or if this row is stale.