MCPcopy Create free account
hub / github.com/PyMySQL/mysqlclient / test_duplicated_pk

Function test_duplicated_pk

tests/test_errors.py:44–56  ·  view source on GitHub ↗

Inserting row with duplicated PK

()

Source from the content-addressed store, hash-verified

42
43
44def test_duplicated_pk():
45 """Inserting row with duplicated PK"""
46 # https://github.com/PyMySQL/mysqlclient/issues/535
47 table_name = "test_duplicated_pk"
48 conn = connect()
49 cursor = conn.cursor()
50
51 cursor.execute(f"create table {table_name} (c1 int primary key)")
52 _tables.append(table_name)
53
54 cursor.execute(f"insert into {table_name} values (1)")
55 with pytest.raises(MySQLdb.IntegrityError):
56 cursor.execute(f"insert into {table_name} values (1)")

Callers

nothing calls this directly

Calls 3

cursorMethod · 0.80
executeMethod · 0.80
connectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…