executemany should work with "insert ... on update
(self)
| 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 |
| 431 | into bulkinsert (id, name, |
| 432 | age, height) |
| 433 | values (%s, |
| 434 | %s , %s, |
| 435 | %s ) on duplicate key update |
| 436 | age = values(age) |
| 437 | """, |
| 438 | data, |
| 439 | ) |
| 440 | self.assertEqual( |
| 441 | cursor._executed.strip(), |
| 442 | bytearray( |
| 443 | b"""insert |
| 444 | into bulkinsert (id, name, |
| 445 | age, height) |
| 446 | values (0, |
| 447 | 'bob' , 21, |
| 448 | 123 ),(1, |
| 449 | 'jim' , 56, |
| 450 | 45 ),(2, |
| 451 | 'fred' , 100, |
| 452 | 180 ) on duplicate key update |
| 453 | age = values(age)""" |
| 454 | ), |
| 455 | ) |
| 456 | cursor.execute("commit") |
| 457 | self._verify_records(data) |
nothing calls this directly
no test coverage detected