Implement sqlite3_column_name and helper function to return column names

This commit is contained in:
Jayson Reis
2018-06-22 15:38:53 +02:00
parent e0793a38a6
commit fce61e13ad
2 changed files with 20 additions and 1 deletions

View File

@ -55,6 +55,21 @@ impl<'l> Statement<'l> {
unsafe { ffi::sqlite3_column_count(self.raw.0) as usize }
}
/// Return the name of a column in the statement
#[inline]
pub fn column_name(&self, i: usize) -> String {
unsafe {
let ret = ffi::sqlite3_column_name(self.raw.0, i as c_int);
c_str_to_string!(ret)
}
}
/// Return column names in the statement
#[inline]
pub fn column_names(&self) -> Vec<String> {
(0..self.columns()).map(|i| self.column_name(i)).collect()
}
/// Return the type of a column.
///
/// The type is revealed after the first step has been taken.