Exemplo n.º 1
0
 def fetchallnumpy(self):
     self._assert_valid_result_set()
     if _has_numpy_support():
         from turbodbc_numpy_support import make_numpy_result_set
         numpy_result_set = make_numpy_result_set(self.impl.get_result_set())
         column_names = [description[0] for description in self.description]
         columns = zip(column_names,
                       [_make_masked_array(data, mask) for data, mask in numpy_result_set.fetch_all()])
         return OrderedDict(columns)
     else:
         raise Error("turbodbc was compiled without numpy support. Please install "
                     "numpy and reinstall turbodbc")
Exemplo n.º 2
0
    def _numpy_batch_generator(self):
        self._assert_valid_result_set()
        if not _has_numpy_support():
            raise Error(_NO_NUMPY_SUPPORT_MSG)

        from turbodbc_numpy_support import make_numpy_result_set
        numpy_result_set = make_numpy_result_set(self.impl.get_result_set())
        first_run = True
        while True:
            result_batch = _make_masked_arrays(numpy_result_set.fetch_next_batch())
            is_empty_batch = (len(result_batch[0]) == 0)
            if is_empty_batch and not first_run:
                raise StopIteration # Let us return a typed result set at least once
            first_run = False
            yield result_batch
Exemplo n.º 3
0
 def fetchallnumpy(self):
     self._assert_valid_result_set()
     if _has_numpy_support():
         from turbodbc_numpy_support import make_numpy_result_set
         numpy_result_set = make_numpy_result_set(
             self.impl.get_result_set())
         column_names = [description[0] for description in self.description]
         columns = zip(column_names, [
             _make_masked_array(data, mask)
             for data, mask in numpy_result_set.fetch_all()
         ])
         return OrderedDict(columns)
     else:
         raise Error(
             "turbodbc was compiled without numpy support. Please install "
             "numpy and reinstall turbodbc")
Exemplo n.º 4
0
 def _numpy_batch_generator(self):
     self._assert_valid_result_set()
     if _has_numpy_support():
         from turbodbc_numpy_support import make_numpy_result_set
     else:
         raise Error(
             "turbodbc was compiled without numpy support. Please install "
             "numpy and reinstall turbodbc")
     numpy_result_set = make_numpy_result_set(self.impl.get_result_set())
     first_run = True
     while True:
         result_batch = _make_masked_arrays(
             numpy_result_set.fetch_next_batch())
         is_empty_batch = (len(result_batch[0]) == 0)
         if is_empty_batch and not first_run:
             raise StopIteration  # Let us return a typed result set at least once
         first_run = False
         yield result_batch