Answer the question
In order to leave comments, you need to log in
How to catch exeption output in flask?
All greetings
Prompt please, solution of a situation:
In a DB (sqllite) two fields are unique. When adding a "duplicate" value to the database via webcam, an exeption
(IntegrityError) UNIQUE constraint failed: nnn.n_id u'INSERT INTO nnn (o_name, n_name, n_id) VALUES (?, ?, ?)' (u'one', u 'one1', u'uno1')
(that is, there is already such a value for the n_id field).
You need to use flash to display the name of the field in the webcam, which is unique (out of 6 of them in the database, 2).
I'm trying the option through parsing sys.exc_info (), but is there a better option? for example exeptions of integretyerror contain arguments, where is the name of the unique field written?
Thanks
Answer the question
In order to leave comments, you need to log in
class IntegrityError(DatabaseError):
"""Wraps a DB-API IntegrityError."""
class DatabaseError(DBAPIError):
"""Wraps a DB-API DatabaseError."""
try:
f = open('myfile.txt')
s = f.readline()
i = int(s.strip())
except IOError as e:
print "I/O error({0}): {1}".format(e.errno, e.strerror)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question