Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法访问SQLAlchemy中的PostgreSQL SQLSTATE代码?_Postgresql_Error Handling_Sqlalchemy - Fatal编程技术网

有没有办法访问SQLAlchemy中的PostgreSQL SQLSTATE代码?

有没有办法访问SQLAlchemy中的PostgreSQL SQLSTATE代码?,postgresql,error-handling,sqlalchemy,Postgresql,Error Handling,Sqlalchemy,我正在寻找一种从SQLAlchemy获取PostgreSQL异常中的错误代码的方法 有办法吗。谢谢是的,你可以。可在orig.pgcode成员上获得 e、 g 将sqlalchemy作为sa导入 尝试: exec_数据库_脚本(…) 除sa.exc.IntegrityError为e外: pgcode=int(例如原始pgcode) 如果pgcode==23514: 打印(“检查约束冲突!”)

我正在寻找一种从SQLAlchemy获取PostgreSQL异常中的错误代码的方法


有办法吗。谢谢

是的,你可以。可在
orig.pgcode
成员上获得

e、 g

将sqlalchemy作为sa导入
尝试:
exec_数据库_脚本(…)
除sa.exc.IntegrityError为e外:
pgcode=int(例如原始pgcode)
如果pgcode==23514:
打印(“检查约束冲突!”)