MCPcopy Index your code
hub / github.com/PyMySQL/PyMySQL / test_issue_288

Method test_issue_288

pymysql/tests/test_basic.py:424–457  ·  view source on GitHub ↗

executemany should work with "insert ... on update

(self)

Source from the content-addressed store, hash-verified

422 self._verify_records(data)
423
424 def test_issue_288(self):
425 """executemany should work with "insert ... on update"""
426 conn = self.connect()
427 cursor = conn.cursor()
428 data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
429 cursor.executemany(
430 """insert
431into bulkinsert (id, name,
432age, height)
433values (%s,
434%s , %s,
435%s ) on duplicate key update
436age = values(age)
437 """,
438 data,
439 )
440 self.assertEqual(
441 cursor._executed.strip(),
442 bytearray(
443 b"""insert
444into bulkinsert (id, name,
445age, height)
446values (0,
447'bob' , 21,
448123 ),(1,
449'jim' , 56,
45045 ),(2,
451'fred' , 100,
452180 ) on duplicate key update
453age = values(age)"""
454 ),
455 )
456 cursor.execute("commit")
457 self._verify_records(data)

Callers

nothing calls this directly

Calls 5

_verify_recordsMethod · 0.95
cursorMethod · 0.80
executemanyMethod · 0.80
executeMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected