def get_rows(self, cnt=None): """Get all rows Returns a tuple with 2 elements: a list with all rows and the EOF packet. """ rows = [] eof = None rowdata = None i = 0 while True: if eof is not None: break if i == cnt: break buf = self._recv_packet() if buf[4] == '\xfe': eof = self._handle_eof(buf) rowdata = None else: eof = None rowdata = utils.read_lc_string_list(buf[4:]) if eof is None and rowdata is not None: rows.append(rowdata) i += 1 return (rows,eof)
def get_rows(self, cnt=None): """Get all rows Returns a tuple with 2 elements: a list with all rows and the EOF packet. """ rows = [] eof = None rowdata = None i = 0 while True: if eof is not None: break if i == cnt: break buf = self._recv_packet() if buf[4] == '\xfe': eof = self._handle_eof(buf) rowdata = None else: eof = None rowdata = utils.read_lc_string_list(buf[4:]) if eof is None and rowdata is not None: rows.append(rowdata) i += 1 return (rows, eof)
def read_text_result(self, sock, count=1): """Read MySQL text result Reads all or given number of rows from the socket. Returns a tuple with 2 elements: a list with all rows and the EOF packet. """ rows = [] eof = None rowdata = None i = 0 while True: if eof is not None: break if i == count: break packet = sock.recv() if packet[0:3] == '\xff\xff\xff': data = packet[4:] packet = sock.recv() while packet[0:3] == '\xff\xff\xff': data += packet[4:] packet = sock.recv() if packet[4] == '\xfe': eof = self.parse_eof(packet) else: data += packet[4:] rowdata = utils.read_lc_string_list(data) elif packet[4] == '\xfe': eof = self.parse_eof(packet) rowdata = None else: eof = None rowdata = utils.read_lc_string_list(packet[4:]) if eof is None and rowdata is not None: rows.append(rowdata) i += 1 return (rows, eof)
def result_get_row(self): """Get data for 1 row Get one row's data. Should be called after getting the field descriptions. Returns a tuple with 2 elements: a row's data and the EOF packet. """ buf = self.conn().recv()[0] if self.is_eof(buf): eof = EOFPacket(buf) rowdata = None else: eof = None rowdata = utils.read_lc_string_list(buf[4:]) return (rowdata, eof)