def build_row_factory(conn):
    cur = conn.cursor()
    cur.execute("pragma table_info('samples')")
    cols = cur.fetchall()
    column_metadata = dict([(col[1], col[2]) for col in cols])

    def row_factory(cursor, row):
        row_dict = dict()
        for idx, desc in enumerate(cursor.description):
            col_name = desc[0]
            col_val = row[idx]
            try:
                row_dict[col_name] = \
                    S2P_MAPPING[column_metadata[col_name]](col_val)
            except KeyError:
                raise UnsupportedTypeException(
                    'A column in the SQLite samples '
                    'database has an unsupported type. '
                    'Supported types are %s. ' % str(S2P_MAPPING.keys()))
        return row_dict

    return row_factory
Introspect the samples table
dataset/ETHPy150Open eBay/bayesian-belief-networks/bayesian/persistance.py/build_row_factory