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

Function _send_local_file

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

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

Callers 1

Calls 2

write_packetMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected