FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Refactor LOAD LOCAL INFILE handling by methane · Pull Request #1264 · PyMySQL/PyMySQL · GitHub

Refactor LOAD LOCAL INFILE handling - #1264

Merged
methane merged 1 commit into
PyMySQL:mainfrom
methane:refactor-load-local-infile
Aug 18, 2026
Merged

Refactor LOAD LOCAL INFILE handling#1264
methane merged 1 commit into
PyMySQL:mainfrom
methane:refactor-load-local-infile

Conversation

methane commented Aug 18, 2026

Copy link
Copy Markdown
Member

Read the OK packet just after sending the EOF (enpty) packet.

There is no problem with bare except clauses, but many people keep sending PRs to remove them, so we rewrite them using finally.

Read the OK packet just after sending the EOF (enpty) packet.

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.51%. Comparing base (1e28be8) to head (70694b1).
⚠️ Report is 65 commits behind head on main.

Files with missing lines Patch % Lines
pymysql/connections.py 90.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1264      +/-   ##
==========================================
- Coverage   86.24%   84.51%   -1.74%     
==========================================
  Files          17       17              
  Lines        2436     2460      +24     
  Branches      258      247      -11     
==========================================
- Hits         2101     2079      -22     
- Misses        249      304      +55     
+ Partials       86       77       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Pull request overview

Refactors the client-side LOAD DATA LOCAL INFILE handling in pymysql/connections.py to align packet sequencing (send the empty/EOF packet, then immediately read the server’s response) and to simplify the local-file sending implementation.

Changes:

  • Refactored LOAD LOCAL INFILE flow to read the OK packet immediately after sending the terminating empty packet.
  • Replaced the LoadLocalFile helper class with a module-level _send_local_file() function.
  • Minor cleanup in OK packet handling and connection exception classification.
Suppressed comments (1)

pymysql/connections.py:1446

  • _send_local_file() no longer checks that the connection has an active socket; if conn._sock is None (e.g., connection closed mid-transfer), conn.write_packet() will raise an AttributeError. Add an explicit InterfaceError guard like other write paths use.
def _send_local_file(filename: str, conn: Connection):
    """Send data packets from the local file to the server"""
    packet_size = min(conn.max_allowed_packet, 16 * 1024)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pymysql/connections.py
Comment on lines +1296 to +1303
finally:
# send the empty packet to signify we are done sending data
conn.write_packet(b"")
ok_packet = conn._read_packet()
# If an error occurs while sending the file, exit here without handling
# the OK packet.

ok_packet = self.connection._read_packet()
if (
not ok_packet.is_ok_packet()
): # pragma: no cover - upstream induced protocol error
if not ok_packet.is_ok_packet():
methane merged commit 0305ab3 into PyMySQL:main Aug 18, 2026
13 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL