B
B
beduin012017-10-18 19:51:16
Python
beduin01, 2017-10-18 19:51:16

How to catch error in psycopg2 request?

There is a code:

def removeEmail(email):
    try:
        print(email)
        sql = """DELETE FROM "НеправильнаяТаблица" WHERE email = '[email protected]'"""
        cur.execute(sql)
        return successResponse
    except psycopg2.Error as e:
        logging.exception(e.pgerror)
        return failResponse

This code will catch the error in the driver, but not in the request itself. What if you need to catch an error in the request?
UPD: I'm sorry, it crashes, only the error is written to the log file, so the crash doesn't go away noticeably.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2017-10-18
@BuriK666

There should be no requests with errors in the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question