how to import aiomysql errors #717
-
i want to make a error handle |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, unfortunately this question is quite old and therefore probably not relevant anymore. example: from pymysql.constants import ER
try:
await cursor.execute("select 1 from foo")
except aiomysql.ProgrammingError as e:
if e.args[0] == ER.NO_SUCH_TABLE: # 1146
print("table doesn't exist")
else:
raise e |
Beta Was this translation helpful? Give feedback.
Hi,
unfortunately this question is quite old and therefore probably not relevant anymore.
aiomysql generally raises the same error types as PyMySQL (where applicable).
for convenience we also provide the PyMySQL error types in the aiomysql package.
in case of an incorrect table name
foo
this raisespymysql.err.ProgrammingError: (1146, "Table 'mysql.foo' doesn't exist")
.the error code will be available in
e.args[0]
.example: