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

Function _send_local_file

pymysql/connections.py:1502–1518  ·  view source on GitHub ↗

Send data packets from the local file to the server

(filename: str, conn: Connection)

Source from the content-addressed store, hash-verified

1500
1501
1502def _send_local_file(filename: str, conn: Connection):
1503 """Send data packets from the local file to the server"""
1504 packet_size = min(conn.max_allowed_packet, 16 * 1024)
1505
1506 try:
1507 with open(filename, "rb") as file:
1508 # 16KB is efficient enough
1509 while True:
1510 chunk = file.read(packet_size)
1511 if not chunk:
1512 break
1513 conn.write_packet(chunk)
1514 except OSError as e:
1515 raise err.OperationalError(
1516 ER.FILE_NOT_FOUND,
1517 f"Can't open file '{filename}': {e}",
1518 )

Callers 1

Calls 2

write_packetMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected