当数据库抛出超时错误时,如何让我的python脚本退出?如果我按ctrl-c手动退出,我只收到消息 - 我想让python到立即停止错误..
#!/usr/bin/python
import pyodbc
conn = pyodbc.connect("DSN=OurDSN", autocommit=True)
cursor = conn.cursor()
query = "SELECT * FROM our_table limit 100"
for row in cursor.execute(query):
print row
错误讯息:
"Traceback (most recent call last):
File "./impala_test.py", line 6, in <module>
conn = pyodbc.connect("OurDSN=Hive", autocommit=True)
pyodbc.Error: ('HY000', '[HY000] [unixODBC][Cloudera][HiveODBC] (34) Error from Hive: EAGAIN (timed out). (34) (SQLDriverConnect)')"