gpt4 book ai didi

python - cx_Oracle : how do I get the ORA-xxxxx error number?

转载 作者:行者123 更新时间:2023-11-28 20:00:22 25 4
gpt4 key购买 nike

在 try/except block 中,如何提取 Oracle 错误号?

最佳答案

try:
cursor.execute("select 1 / 0 from dual")
except cx_Oracle.DatabaseError, e:
error, = e
print "Code:", error.code
print "Message:", error.message

这会产生以下输出:

Code: 1476
Message: ORA-01476: divisor is equal to zero

关于python - cx_Oracle : how do I get the ORA-xxxxx error number?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com