| 1178 | |
| 1179 | |
| 1180 | class MySQLResult: |
| 1181 | def __init__(self, connection): |
| 1182 | """ |
| 1183 | :type connection: Connection |
| 1184 | """ |
| 1185 | self.connection = connection |
| 1186 | self.affected_rows = None |
| 1187 | self.insert_id = None |
| 1188 | self.server_status = None |
| 1189 | self.warning_count = 0 |
| 1190 | self.message = None |
| 1191 | self.field_count = 0 |
| 1192 | self.description = None |
| 1193 | self.rows = None |
| 1194 | self.has_next = None |
| 1195 | self.unbuffered_active = False |
| 1196 | |
| 1197 | def __del__(self): |
| 1198 | if self.unbuffered_active: |
| 1199 | self._finish_unbuffered_query() |
| 1200 | |
| 1201 | def read(self): |
| 1202 | try: |
| 1203 | first_packet = self.connection._read_packet() |
| 1204 | |
| 1205 | if first_packet.is_ok_packet(): |
| 1206 | self._read_ok_packet(first_packet) |
| 1207 | elif first_packet.is_load_local_packet(): |
| 1208 | self._read_load_local_packet(first_packet) |
| 1209 | else: |
| 1210 | self._read_result_packet(first_packet) |
| 1211 | finally: |
| 1212 | self.connection = None |
| 1213 | |
| 1214 | def init_unbuffered_query(self): |
| 1215 | """ |
| 1216 | :raise OperationalError: If the connection to the MySQL server is lost. |
| 1217 | :raise InternalError: |
| 1218 | """ |
| 1219 | first_packet = self.connection._read_packet() |
| 1220 | |
| 1221 | if first_packet.is_ok_packet(): |
| 1222 | self.connection = None |
| 1223 | self._read_ok_packet(first_packet) |
| 1224 | elif first_packet.is_load_local_packet(): |
| 1225 | try: |
| 1226 | self._read_load_local_packet(first_packet) |
| 1227 | finally: |
| 1228 | self.connection = None |
| 1229 | else: |
| 1230 | self.field_count = first_packet.read_length_encoded_integer() |
| 1231 | self._get_descriptions() |
| 1232 | |
| 1233 | # Apparently, MySQLdb picks this number because it's the maximum |
| 1234 | # value of a 64bit unsigned integer. Since we're emulating MySQLdb, |
| 1235 | # we set it to this instead of None, which would be preferred. |
| 1236 | self.affected_rows = 18446744073709551615 |
| 1237 | self.unbuffered_active = True |
no outgoing calls
no test coverage detected