allow no whitespaces between VALUES
and (
when do bulk insert/replace
#597
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.
the regular expression used to check whether bulk insert/replace is possible is as follows:
notice the last
\s+
in the first part of the regular expression requires whitespaces betweenVALUES
and left-parenthesis, which means queries likeinsert into user values(%s, %s)
would not be considered bulk-insertable. although the demo sql query in the comment ofexecutemany
has a space betweenVALUES
and(
, i do think this restriction could be relaxed.This gotcha is so trivial and would cost some time to realize. It actually costed me some time to find out why the performance of a relatively simple program dropped by more than 6 times after switching from MySQLdb to PyMySQL.
The fix is quite simple, just replace the
\s+
with\s*
in the first part.NOTE: ported from PyMySQL/mysqlclient@354dcb5