server/sqlutils.py
changeset 8139 f9ebb6d1abc3
parent 7907 08320697ca1a
child 8755 1f3757ef3762
equal deleted inserted replaced
8138:86da196640ae 8139:f9ebb6d1abc3
   212         """
   212         """
   213         # use two different implementations to avoid paying the price of
   213         # use two different implementations to avoid paying the price of
   214         # callback lookup for each *cell* in results when there is nothing to
   214         # callback lookup for each *cell* in results when there is nothing to
   215         # lookup
   215         # lookup
   216         if not column_callbacks:
   216         if not column_callbacks:
   217             return self._process_result(cursor)
   217             return self.dbhelper.dbapi_module.process_cursor(cursor, self._dbencoding,
       
   218                                                              Binary)
   218         assert session
   219         assert session
   219         return self._cb_process_result(cursor, column_callbacks, session)
   220         return self._cb_process_result(cursor, column_callbacks, session)
   220 
       
   221     def _process_result(self, cursor):
       
   222         # begin bind to locals for optimization
       
   223         descr = cursor.description
       
   224         encoding = self._dbencoding
       
   225         process_value = self._process_value
       
   226         binary = Binary
       
   227         # /end
       
   228         cursor.arraysize = 100
       
   229         while True:
       
   230             results = cursor.fetchmany()
       
   231             if not results:
       
   232                 break
       
   233             for line in results:
       
   234                 result = []
       
   235                 for col, value in enumerate(line):
       
   236                     if value is None:
       
   237                         result.append(value)
       
   238                         continue
       
   239                     result.append(process_value(value, descr[col], encoding, binary))
       
   240                 yield result
       
   241 
   221 
   242     def _cb_process_result(self, cursor, column_callbacks, session):
   222     def _cb_process_result(self, cursor, column_callbacks, session):
   243         # begin bind to locals for optimization
   223         # begin bind to locals for optimization
   244         descr = cursor.description
   224         descr = cursor.description
   245         encoding = self._dbencoding
   225         encoding = self._dbencoding