问题:使用sqlalchemy连接hive进行创建表操作,当数据表已经存在时会报错,但无法获取具体信息
解决:使用try except捕捉异常信息
方法:
try:
session.execute(sql)
except Exception as e:
code = e.code
tstatus = e.orig.args[0].status
msg = tstatus.errorMessage
参考:
https://blog.csdn.net/macwinwin/article/details/114640945
https://stackoverflow.com/questions/52391688/python-pyhive-extract-specific-error-message-from-exception