I have codes which uses python to insert data from excel into mysql.
I am trying to catch some error message and display more clear information to the end user, like:
if you are trying to insert NaN into mysql, the system show below info:
'''
1054 (42S22): Unknown column 'nan' in 'field list'
'''
How can I catch this error message to display more clear info, like:
if ErrorCode='1054':
print('please check at original file at see whether there is empty value at certain area"
I use
try:
except Exception as:
print(e)
to catch the error message, but this can not show the explicit info.
I might be wrong, please feel free to commet it.
Thanks.
it is quite straight forwar see manual
except mysql.connector.Error as err:
if err.errno == 1054:
print("please check at original file at see whether there is empty value at certain area")
else:
print("Another error")