| 1220 | |
| 1221 | |
| 1222 | class MySQLResult: |
| 1223 | def __init__(self, connection): |
| 1224 | """ |
| 1225 | :type connection: Connection |
| 1226 | """ |
| 1227 | self.connection = connection |
| 1228 | self.affected_rows = None |
| 1229 | self.insert_id = None |
| 1230 | self.server_status = None |
| 1231 | self.warning_count = 0 |
| 1232 | self.message = None |
| 1233 | self.field_count = 0 |
| 1234 | self.description = None |
| 1235 | self.rows = None |
| 1236 | self.has_next = None |
| 1237 | self.unbuffered_active = False |
| 1238 | |
| 1239 | def __del__(self): |
| 1240 | if self.unbuffered_active: |
| 1241 | self._finish_unbuffered_query() |
| 1242 | |
| 1243 | def read(self): |
| 1244 | try: |
| 1245 | first_packet = self.connection._read_packet() |
| 1246 | |
| 1247 | if first_packet.is_ok_packet(): |
| 1248 | self._read_ok_packet(first_packet) |
| 1249 | elif first_packet.is_load_local_packet(): |
| 1250 | self._read_load_local_packet(first_packet) |
| 1251 | else: |
| 1252 | self._read_result_packet(first_packet) |
| 1253 | finally: |
| 1254 | self.connection = None |
| 1255 | |
| 1256 | def init_unbuffered_query(self): |
| 1257 | """ |
| 1258 | :raise OperationalError: If the connection to the MySQL server is lost. |
| 1259 | :raise InternalError: |
| 1260 | """ |
| 1261 | first_packet = self.connection._read_packet() |
| 1262 | |
| 1263 | if first_packet.is_ok_packet(): |
| 1264 | self.connection = None |
| 1265 | self._read_ok_packet(first_packet) |
| 1266 | elif first_packet.is_load_local_packet(): |
| 1267 | try: |
| 1268 | self._read_load_local_packet(first_packet) |
| 1269 | finally: |
| 1270 | self.connection = None |
| 1271 | else: |
| 1272 | self.field_count = first_packet.read_length_encoded_integer() |
| 1273 | self._get_descriptions() |
| 1274 | |
| 1275 | # Apparently, MySQLdb picks this number because it's the maximum |
| 1276 | # value of a 64bit unsigned integer. Since we're emulating MySQLdb, |
| 1277 | # we set it to this instead of None, which would be preferred. |
| 1278 | self.affected_rows = 18446744073709551615 |
| 1279 | self.unbuffered_active = True |
no outgoing calls
no test coverage detected
searching dependent graphs…