MCPcopy Create free account
hub / github.com/PyMySQL/PyMySQL / test_issue_288

Method test_issue_288

pymysql/tests/test_basic.py:423–456  ·  view source on GitHub ↗

executemany should work with "insert ... on update

(self)

Source from the content-addressed store, hash-verified

421 self._verify_records(data)
422
423 def test_issue_288(self):
424 """executemany should work with "insert ... on update"""
425 conn = self.connect()
426 cursor = conn.cursor()
427 data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
428 cursor.executemany(
429 """insert
430into bulkinsert (id, name,
431age, height)
432values (%s,
433%s , %s,
434%s ) on duplicate key update
435age = values(age)
436 """,
437 data,
438 )
439 self.assertEqual(
440 cursor._executed.strip(),
441 bytearray(
442 b"""insert
443into bulkinsert (id, name,
444age, height)
445values (0,
446'bob' , 21,
447123 ),(1,
448'jim' , 56,
44945 ),(2,
450'fred' , 100,
451180 ) on duplicate key update
452age = values(age)"""
453 ),
454 )
455 cursor.execute("commit")
456 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