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

Method test_issue_288

pymysql/tests/test_basic.py:444–477  ·  view source on GitHub ↗

executemany should work with "insert ... on update

(self)

Source from the content-addressed store, hash-verified

442 self._verify_records(data)
443
444 def test_issue_288(self):
445 """executemany should work with "insert ... on update"""
446 conn = self.connect()
447 cursor = conn.cursor()
448 data = [(0, "bob", 21, 123), (1, "jim", 56, 45), (2, "fred", 100, 180)]
449 cursor.executemany(
450 """insert
451into bulkinsert (id, name,
452age, height)
453values (%s,
454%s , %s,
455%s ) on duplicate key update
456age = values(age)
457 """,
458 data,
459 )
460 self.assertEqual(
461 cursor._executed.strip(),
462 bytearray(
463 b"""insert
464into bulkinsert (id, name,
465age, height)
466values (0,
467'bob' , 21,
468123 ),(1,
469'jim' , 56,
47045 ),(2,
471'fred' , 100,
472180 ) on duplicate key update
473age = values(age)"""
474 ),
475 )
476 cursor.execute("commit")
477 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