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

Class MySQLResult

pymysql/connections.py:1267–1489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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