📜  重复条目异常 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:21.543000             🧑  作者: Mango

代码示例1
import java.lang.Exception
try:
    #Your insert statement here
except Exception, e:
    # Catches any python errors
except java.lang.Exception, e:
    #SQL Integrity errors come as Java errors so you need java.lang.Exception
    if "Duplicate entry" in str(e.cause):
        #Do something to let user know its a duplicate