Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 354dcb5

Browse filesBrowse files
authored
Allow bulk insert which no space around VALUES (PyMySQL#179)
1 parent 1693848 commit 354dcb5
Copy full SHA for 354dcb5

File tree

Expand file treeCollapse file tree

2 files changed

+5
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-1
lines changed

‎MySQLdb/cursors.py

Copy file name to clipboardExpand all lines: MySQLdb/cursors.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#: executemany only supports simple bulk insert.
2727
#: You can use it to load large dataset.
2828
RE_INSERT_VALUES = re.compile(
29-
r"\s*((?:INSERT|REPLACE)\s.+\sVALUES?\s+)" +
29+
r"\s*((?:INSERT|REPLACE)\b.+\bVALUES?\s*)" +
3030
r"(\(\s*(?:%s|%\(.+\)s)\s*(?:,\s*(?:%s|%\(.+\)s)\s*)*\))" +
3131
r"(\s*(?:ON DUPLICATE.*)?);?\s*\Z",
3232
re.IGNORECASE | re.DOTALL)

‎tests/test_cursor.py

Copy file name to clipboardExpand all lines: tests/test_cursor.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def test_executemany():
4949
assert m is not None, 'error parse %(id_name)s'
5050
assert m.group(3) == ' ON duplicate update', 'group 3 not ON duplicate update, bug in RE_INSERT_VALUES?'
5151

52+
# https://github.com/PyMySQL/mysqlclient-python/issues/178
53+
m = MySQLdb.cursors.RE_INSERT_VALUES.match("INSERT INTO bloup(foo, bar)VALUES(%s, %s)")
54+
assert m is not None
55+
5256
# cursor._executed myst bee "insert into test (data) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9)"
5357
# list args
5458
data = range(10)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.