N
N
nano_e_t_42015-10-31 16:54:38
Flask
nano_e_t_4, 2015-10-31 16:54:38

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

1 answer(s)
V
Vladimir Abiduev, 2015-11-05
@gunlinux

class IntegrityError(DatabaseError):
    """Wraps a DB-API IntegrityError."""

class DatabaseError(DBAPIError):
    """Wraps a DB-API DatabaseError."""

https://github.com/zzzeek/sqlalchemy/blob/7393ee8d...
from line 253
Well, then something like this.
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)

And for God's sake, I spent more time trying to read the question, fu be like that

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question