MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / MySQLResult

Class MySQLResult

pymysql/connections.py:1265–1487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

show_warningsMethod · 0.85
_read_query_resultMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected