| 1275 | |
| 1276 | |
| 1277 | class MySQLResult: |
| 1278 | def __init__(self, connection): |
| 1279 | """ |
| 1280 | :type connection: Connection |
| 1281 | """ |
| 1282 | self.connection = connection |
| 1283 | self.affected_rows = None |
| 1284 | self.insert_id = None |
| 1285 | self.server_status = None |
| 1286 | self.warning_count = 0 |
| 1287 | self.message = None |
| 1288 | self.field_count = 0 |
| 1289 | self.description = None |
| 1290 | self.rows = None |
| 1291 | self.has_next = None |
| 1292 | self.unbuffered_active = False |
| 1293 | |
| 1294 | def __del__(self): |
| 1295 | if self.unbuffered_active: |
| 1296 | self._finish_unbuffered_query() |
| 1297 | |
| 1298 | def read(self): |
| 1299 | try: |
| 1300 | first_packet = self.connection._read_packet() |
| 1301 | |
| 1302 | if first_packet.is_ok_packet(): |
| 1303 | self._read_ok_packet(first_packet) |
| 1304 | elif first_packet.is_load_local_packet(): |
| 1305 | self._read_load_local_packet(first_packet) |
| 1306 | else: |
| 1307 | self._read_result_packet(first_packet) |
| 1308 | finally: |
| 1309 | self.connection = None |
| 1310 | |
| 1311 | def init_unbuffered_query(self): |
| 1312 | """ |
| 1313 | :raise OperationalError: If the connection to the MySQL server is lost. |
| 1314 | :raise InternalError: |
| 1315 | """ |
| 1316 | first_packet = self.connection._read_packet() |
| 1317 | |
| 1318 | if first_packet.is_ok_packet(): |
| 1319 | self.connection = None |
| 1320 | self._read_ok_packet(first_packet) |
| 1321 | elif first_packet.is_load_local_packet(): |
| 1322 | try: |
| 1323 | self._read_load_local_packet(first_packet) |
| 1324 | finally: |
| 1325 | self.connection = None |
| 1326 | else: |
| 1327 | self.field_count = first_packet.read_length_encoded_integer() |
| 1328 | self._get_descriptions() |
| 1329 | |
| 1330 | # Apparently, MySQLdb picks this number because it's the maximum |
| 1331 | # value of a 64bit unsigned integer. Since we're emulating MySQLdb, |
| 1332 | # we set it to this instead of None, which would be preferred. |
| 1333 | self.affected_rows = 18446744073709551615 |
| 1334 | self.unbuffered_active = True |
no outgoing calls
no test coverage detected