ColumnConvertible

public protocol ColumnConvertible

A type that can be initialized directly from a column in an SQLite result row.

The implementation should use one of the sqlite_column_X() functions documented at Result Values From A Query.

For example, the implementation for Int64 is:

extension Int64: ColumnConvertible {
    public init(_ stmt: SQLitePreparedStatement, column idx: Int32) {
       self = sqlite3_column_int64(stmt, idx)
    }
}
  • Creates an instance containing the value of column idx in stmt.

    Note

    Column indexes are 0-based. The leftmost column in a row has index 0.

    Precondition

    sqlite3_column_type(stmt, idx) != SQLITE_NULL

    Throws

    An error if initialization fails

    Declaration

    Swift

    init(_ stmt: SQLitePreparedStatement, column idx: Int32) throws

    Parameters

    stmt

    An sqlite3_stmt * object

    idx

    The index of the desired column