Skip to content

Allow semicolon at the end of bulk insert query #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2017
Merged

Allow semicolon at the end of bulk insert query #545

merged 3 commits into from
Feb 28, 2017

Conversation

gyli
Copy link

@gyli gyli commented Feb 2, 2017

When running bulk insert with executemany(), the regex should allow semicolon at the end of the query.

@@ -14,7 +14,7 @@
RE_INSERT_VALUES = re.compile(
r"\s*((?:INSERT|REPLACE)\s.+\sVALUES?\s+)" +
r"(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))" +
r"(\s*(?:ON DUPLICATE.*)?)\Z",
r"(\s*(?:ON DUPLICATE.*)?)(;*\s*)\Z",
Copy link
Member

Choose a reason for hiding this comment

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

Why do you use group?

@methane
Copy link
Member

methane commented Feb 2, 2017

Generally speaking, I don't want to support full SQL. I hate complex regular expression too.
If someone want to use executemany()'s bulk insert, they should fix SQL to match the pattern.

But in this case, allowing semicolon seems simple enough to accept.

@gyli
Copy link
Author

gyli commented Feb 2, 2017

You are right, no need for group.

@methane methane merged commit 103a00d into PyMySQL:master Feb 28, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants