TDengine/docs-examples/python/handle_exception.py
Bo Ding 8d15fc7209
docs: python connector document part2 (#11941)
* docs: python document part2

* docs: refine some words

* docs: typo
2022-04-27 15:49:14 +08:00

23 lines
615 B
Python

import taos
conn: taos.TaosConnection = None
try:
conn = taos.connect()
conn.execute("CREATE TABLE 123") # wrong sql
except taos.Error as e:
print(e)
print("exception class: ", e.__class__.__name__)
print("error number:", e.errno)
print("error message:", e.msg)
except BaseException as other:
print("exception occur")
print(other)
finally:
if conn is not None:
conn.close()
# output:
# [0x0216]: syntax error near 'Incomplete SQL statement'
# exception class: ProgrammingError
# error number: -2147483114
# error message: syntax error near 'Incomplete SQL statement'