nirbarazida / Data-mining-project

ITC - Data mining project
0 stars 1 forks source link

working with database - try/except #12

Closed InbarShirizly closed 4 years ago

InbarShirizly commented 4 years ago

there should not be more that 1 try/except per function. If there is more that 1 try/except then the function needs to be refector into many smaller functions

` try: connection = pymysql.connect(host='localhost', user=conf.USER_NAME, password=conf.PASSWORD) except pymysql.err.OperationalError as err: logger_DB.error(conf.CONNECTION_ERROR) exit() else:

Create a cursor object

    try:
        cursor_instance = connection.cursor()
    except pymysql.err.OperationalError:
        logger_DB.error(conf.SERVER_ERROR)
        exit()`
InbarShirizly commented 4 years ago

In which circumstances we get this error @nirbarazida?

image