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

Function _send_local_file

pymysql/connections.py:1490–1506  ·  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

1488
1489
1490def _send_local_file(filename: str, conn: Connection):
1491 """Send data packets from the local file to the server"""
1492 packet_size = min(conn.max_allowed_packet, 16 * 1024)
1493
1494 try:
1495 with open(filename, "rb") as file:
1496 # 16KB is efficient enough
1497 while True:
1498 chunk = file.read(packet_size)
1499 if not chunk:
1500 break
1501 conn.write_packet(chunk)
1502 except OSError as e:
1503 raise err.OperationalError(
1504 ER.FILE_NOT_FOUND,
1505 f"Can't open file '{filename}': {e}",
1506 )

Callers 1

Calls 2

write_packetMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected