def _parse(self): buf = self.data (buf,self.field_count) = utils.read_int(buf,1) (buf,self.affected_rows) = utils.read_lc_int(buf) (buf,self.insert_id) = utils.read_lc_int(buf) (buf,self.server_status) = utils.read_int(buf,2) (buf,self.warning_count) = utils.read_int(buf,2) if buf: (buf,self.info_msg) = utils.read_lc_string(buf)
def _pkt_parse_ok(self, buf): """Parse a MySQL OK-packet""" ok = {} (buf,ok['field_count']) = utils.read_int(buf,1) (buf,ok['affected_rows']) = utils.read_lc_int(buf) (buf,ok['insert_id']) = utils.read_lc_int(buf) (buf,ok['server_status']) = utils.read_int(buf,2) (buf,ok['warning_count']) = utils.read_int(buf,2) if buf: (buf,ok['info_msg']) = utils.read_lc_string(buf) return ok
def _pkt_parse_field(self, buf): """Parse a MySQL Field-packet""" field = {} (buf,field['catalog']) = utils.read_lc_string(buf) (buf,field['db']) = utils.read_lc_string(buf) (buf,field['table']) = utils.read_lc_string(buf) (buf,field['org_table']) = utils.read_lc_string(buf) (buf,field['name']) = utils.read_lc_string(buf) (buf,field['org_name']) = utils.read_lc_string(buf) buf = buf[1:] # filler 1 * \x00 (buf,field['charset']) = utils.read_int(buf, 2) (buf,field['length']) = utils.read_int(buf, 4) (buf,field['type']) = utils.read_int(buf, 1) (buf,field['flags']) = utils.read_int(buf, 2) (buf,field['decimal']) = utils.read_int(buf, 1) buf = buf[2:] # filler 2 * \x00 res = ( field['name'], field['type'], None, # display_size None, # internal_size None, # precision None, # scale ~field['flags'] & FieldFlag.NOT_NULL, # null_ok field['flags'], # MySQL specific ) return res
def parse_column(self, packet): """Parse a MySQL column-packet""" column = {} (packet, column['catalog']) = utils.read_lc_string(packet[4:]) (packet, column['db']) = utils.read_lc_string(packet) (packet, column['table']) = utils.read_lc_string(packet) (packet, column['org_table']) = utils.read_lc_string(packet) (packet, column['name']) = utils.read_lc_string(packet) (packet, column['org_name']) = utils.read_lc_string(packet) packet = packet[1:] # filler 1 * \x00 (packet, column['charset']) = utils.read_int(packet, 2) (packet, column['length']) = utils.read_int(packet, 4) (packet, column['type']) = utils.read_int(packet, 1) (packet, column['flags']) = utils.read_int(packet, 2) (packet, column['decimal']) = utils.read_int(packet, 1) packet = packet[2:] # filler 2 * \x00 return ( column['name'], column['type'], None, # display_size None, # internal_size None, # precision None, # scale ~column['flags'] & FieldFlag.NOT_NULL, # null_ok column['flags'], # MySQL specific )
def parse_ok(self, packet): """Parse a MySQL OK-packet""" if not packet[4] == '\x00': raise errors.InterfaceError("Failed parsing OK packet.") ok = {} try: (packet, ok['field_count']) = utils.read_int(packet[4:], 1) (packet, ok['affected_rows']) = utils.read_lc_int(packet) (packet, ok['insert_id']) = utils.read_lc_int(packet) (packet, ok['server_status']) = utils.read_int(packet, 2) (packet, ok['warning_count']) = utils.read_int(packet, 2) if packet: (packet, ok['info_msg']) = utils.read_lc_string(packet) except ValueError: raise errors.InterfaceError("Failed parsing OK packet.") return ok
def _parse(self): buf = self.data (buf,self.catalog) = utils.read_lc_string(buf) (buf,self.db) = utils.read_lc_string(buf) (buf,self.table) = utils.read_lc_string(buf) (buf,self.org_table) = utils.read_lc_string(buf) (buf,self.name) = utils.read_lc_string(buf) (buf,self.org_name) = utils.read_lc_string(buf) buf = buf[1:] # filler 1 * \x00 (buf,self.charset) = utils.read_int(buf, 2) (buf,self.length) = utils.read_int(buf, 4) (buf,self.type) = utils.read_int(buf, 1) (buf,self.flags) = utils.read_int(buf, 2) (buf,self.decimal) = utils.read_int(buf, 1) buf = buf[2:] # filler 2 * \x00