Enable MySQL "LOAD DATA LOCAL" with url option#4970
Merged
weiznich merged 1 commit intodiesel-rs:mainfrom Mar 20, 2026
Merged
Conversation
JohnTitor
reviewed
Feb 11, 2026
Member
JohnTitor
left a comment
There was a problem hiding this comment.
Also I'd tweak ConnectionOptions and add tests.
diesel/src/mysql/connection/url.rs
Outdated
| // this is not present in the database_url, using a default value | ||
| let client_flags = CapabilityFlags::CLIENT_FOUND_ROWS; | ||
| let mut client_flags = CapabilityFlags::CLIENT_FOUND_ROWS; | ||
| if query_pairs.contains_key("local_infile") { |
Member
There was a problem hiding this comment.
local_infile should take binary value so we need handle it as well: https://dev.mysql.com/doc/refman/8.4/en/mysql-command-options.html#option_mysql_local-infile
cf7a150 to
a82c10d
Compare
Contributor
Author
|
Initially used mysqlclient's default compiled flag (usually disabled) or explicit enable. To have explicit enable and disable we need to use mysql_option instead. Added parsing unit test. Example above was successful too. |
Contributor
Author
|
Rebased after #4972 so tests pass. Also fixed the doc comment. |
weiznich
approved these changes
Mar 20, 2026
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable LOAD DATA LOCAL in
batch_execute. mysqlclient handles all the IO. I'm inserting 30 million rows significantly faster now.With native Diesel support, the mysql and postgres versions get complicated quickly. Also LOAD DATA isn't supported in transactions. This option is enough for me to do it when rarely needed.
Example