Beispiel #1
0
    def __build_row_cast_map(self):
        if not self.__connection._detect_types:
            return
        self.__row_cast_map = []
        for i in xrange(_lib.sqlite3_column_count(
                self.__statement._statement)):
            converter = None

            if self.__connection._detect_types & PARSE_COLNAMES:
                colname = _lib.sqlite3_column_name(self.__statement._statement,
                                                   i)
                if colname:
                    colname = _ffi.string(colname).decode('utf-8')
                    type_start = -1
                    key = None
                    for pos in range(len(colname)):
                        if colname[pos] == '[':
                            type_start = pos + 1
                        elif colname[pos] == ']' and type_start != -1:
                            key = colname[type_start:pos]
                            converter = converters[key.upper()]

            if converter is None and self.__connection._detect_types & PARSE_DECLTYPES:
                decltype = _lib.sqlite3_column_decltype(
                    self.__statement._statement, i)
                if decltype:
                    decltype = _ffi.string(decltype).decode('utf-8')
                    # if multiple words, use first, eg.
                    # "INTEGER NOT NULL" => "INTEGER"
                    decltype = decltype.split()[0]
                    if '(' in decltype:
                        decltype = decltype[:decltype.index('(')]
                    converter = converters.get(decltype.upper(), None)

            self.__row_cast_map.append(converter)
Beispiel #2
0
    def __build_row_cast_map(self):
        if not self.__connection._detect_types:
            return
        self.__row_cast_map = []
        for i in xrange(_lib.sqlite3_column_count(self.__statement._statement)):
            converter = None

            if self.__connection._detect_types & PARSE_COLNAMES:
                colname = _lib.sqlite3_column_name(self.__statement._statement, i)
                if colname:
                    colname = _ffi.string(colname).decode('utf-8')
                    type_start = -1
                    key = None
                    for pos in range(len(colname)):
                        if colname[pos] == '[':
                            type_start = pos + 1
                        elif colname[pos] == ']' and type_start != -1:
                            key = colname[type_start:pos]
                            converter = converters[key.upper()]

            if converter is None and self.__connection._detect_types & PARSE_DECLTYPES:
                decltype = _lib.sqlite3_column_decltype(self.__statement._statement, i)
                if decltype:
                    decltype = _ffi.string(decltype).decode('utf-8')
                    # if multiple words, use first, eg.
                    # "INTEGER NOT NULL" => "INTEGER"
                    decltype = decltype.split()[0]
                    if '(' in decltype:
                        decltype = decltype[:decltype.index('(')]
                    converter = converters.get(decltype.upper(), None)

            self.__row_cast_map.append(converter)
Beispiel #3
0
 def _get_description(self):
     if self._is_dml:
         return None
     desc = []
     for i in xrange(_lib.sqlite3_column_count(self._statement)):
         name = _lib.sqlite3_column_name(self._statement, i)
         if name:
             name = _ffi.string(name).decode('utf-8').split("[")[0].strip()
         desc.append((name, None, None, None, None, None, None))
     return desc
Beispiel #4
0
 def _get_description(self):
     if self._type in (_STMT_TYPE_INSERT, _STMT_TYPE_UPDATE, _STMT_TYPE_DELETE, _STMT_TYPE_REPLACE):
         return None
     desc = []
     for i in xrange(_lib.sqlite3_column_count(self._statement)):
         name = _lib.sqlite3_column_name(self._statement, i)
         if name:
             name = _ffi.string(name).split("[")[0].strip()
         desc.append((name, None, None, None, None, None, None))
     return desc
Beispiel #5
0
 def _get_description(self):
     if self._type in (_STMT_TYPE_INSERT, _STMT_TYPE_UPDATE,
                       _STMT_TYPE_DELETE, _STMT_TYPE_REPLACE):
         return None
     desc = []
     for i in xrange(_lib.sqlite3_column_count(self._statement)):
         name = _lib.sqlite3_column_name(self._statement, i)
         if name:
             name = _ffi.string(name).split("[")[0].strip()
         desc.append((name, None, None, None, None, None, None))
     return desc