def update_sql(sql): try: cursor = connection.cursor() cursor.execute(sql) return EXECUTE_SUCCESSFULLY except Exception as e: logger.error(sql) logger.error(e) connection.rollback() return UPDATE_SQL_ERROR
def select_many_sql(sql): try: cursor = connection.cursor() cursor.execute(sql) rows = cursor.dictfetchall() return rows except Exception as e: logger.error(sql) logger.error(e) connection.rollback() return SELECT_MANY_SQL_ERROR
def select_one_sql(sql): try: cursor = connection.cursor() cursor.execute(sql) row = cursor.fetchone() return row except Exception as e: logger.error(sql) logger.error(e) connection.rollback() return SELECT_ONE_SQL_ERROR