Exemplo n.º 1
0
    def setData(self, name, img, tid, file, desc, date, res_page):
        fd_obj = FdObj()
        fd_obj.name = name
        fd_obj.image = img
        fd_obj.tid = tid
        fd_obj.file = file

        fd_obj.desc = desc

        fd_obj.date = date
        fd_obj.result_page = res_page
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "insert into tbl_feedbackdata (fd_name, fd_img, td_id, fd_file, fd_desc, upload_date, result_page) values('" + name + "', '" + img + "'," + str(
            tid
        ) + " ,'" + file + "','" + desc + "','" + date + "','" + res_page + "')"
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 2
0
    def setData(self, name, img, file, storage_type, desc, model, date, acc):
        td_obj = TdObj()
        td_obj.name = name
        td_obj.image = img
        td_obj.file = file
        td_obj.storage_type = storage_type
        td_obj.desc = desc
        td_obj.model = model
        td_obj.date = date
        td_obj.accuracy = acc
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "insert into tbl_trainingdata (td_name, td_img, td_file, storage_type, td_desc, td_model, upload_date, model_accuracy) values('" + name + "', '" + img + "', '" + file + "'," + str(
            storage_type
        ) + ",'" + desc + "','" + model + "','" + date + "','" + str(
            acc) + "')"
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 3
0
    def getData(self, given_fd_id):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        mycursor = sql_con.getSQLConn()
        fd_obj = FdObj()
        query = "select * from tbl_feedbackdata where fd_id =" + str(
            given_fd_id)
        #print(query)
        if mycursor[1].execute(query) != 0:

            a = mycursor[1].fetchall()[0]
            fd_obj.fid = a[0]
            fd_obj.name = a[1]
            fd_obj.image = a[2]
            fd_obj.tid = a[3]
            fd_obj.file = a[4]
            fd_obj.desc = a[5]
            fd_obj.date = a[6]
            fd_obj.result_page = a[7]
            mycursor[1].close()
            mycursor[0].close()
            return fd_obj
        else:
            print("No Such ID Present")

        return 0
Exemplo n.º 4
0
    def setData(self, uname_, pwd_, name_, dept_, email_, phone_):
        user_obj = UserObj()
        user_obj.username = uname_
        user_obj.pwd = pwd_
        user_obj.name = name_
        user_obj.dept = dept_
        user_obj.email = email_
        user_obj.phone = phone_
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "insert into tbl_users(u_username, u_pwd, u_name, u_dept, u_email, u_phone) values('" + uname_ + "', '" + pwd_ + "', '" + name_ + "','" + dept_ + "','" + email_ + "','" + phone_ + "')"
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 5
0
    def getData(self, given_td_id):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        mycursor = sql_con.getSQLConn()
        td_obj = TdObj()
        query = "select * from tbl_trainingdata where td_id =" + str(
            given_td_id)
        if mycursor[1].execute(query) != 0:

            a = mycursor[1].fetchall()[0]
            td_obj.id = a[0]
            td_obj.name = a[1]
            td_obj.image = a[2]
            td_obj.file = a[3]
            td_obj.storage_type = a[4]
            td_obj.desc = a[5]
            td_obj.model = a[6]
            td_obj.date = a[7]
            td_obj.accuracy = a[8]
            mycursor[1].close()
            mycursor[0].close()
            return td_obj
        else:
            print("No Such ID Present")

        return 0
Exemplo n.º 6
0
    def delete_dataset(self, dataset_id, file_path, img_path, model_path,
                       token_path):
        from db_access.config import SQLConn
        import os
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        if self.getData(dataset_id) != 0:
            if os.path.exists(img_path):
                os.remove(img_path)
            else:
                print("The image does not exist")
            if os.path.exists(file_path):
                os.remove(file_path)
            else:
                print("The file does not exist")
            if os.path.exists(model_path):
                os.remove(model_path)
            else:
                print("The model (pkl file) does not exist")
            if os.path.exists(token_path):
                os.remove(token_path)
            else:
                print("The token does not exist")

            query1 = "Update tbl_feedbackdata set td_id = " + str(
                sql_con.default_primary_key) + " where td_id = " + str(
                    dataset_id)
            query2 = "Delete from tbl_trainingdata where td_id =" + str(
                dataset_id)

            try:
                obj[1].execute(query1)
                obj[1].execute(query2)

                obj[0].commit()

                return 1
            except:
                obj[0].rollback()
                return 0
            finally:
                obj[1].close()
                obj[0].close()
        else:
            print("No Such Dataset to Delete")
        return 0
Exemplo n.º 7
0
 def getFileNamebyID(self, given_td_id):
     from db_access.config import SQLConn
     sql_con = SQLConn()
     mycursor = sql_con.getSQLConn()
     query = "select td_file from tbl_trainingdata where td_id = '" + str(
         given_td_id) + "'"
     if mycursor[1].execute(query) != 0:
         a = mycursor[1].fetchall()[0]
         td_file = a[0]
         mycursor[1].close()
         mycursor[0].close()
         return td_file
     else:
         print("No Such File Present")
         mycursor[1].close()
         mycursor[0].close()
     return "TD20200309210544.json"
Exemplo n.º 8
0
    def delete_user(self, user_name):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "Delete from tbl_users where u_username = '******'"
        try:
            obj[1].execute(query)

            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()
Exemplo n.º 9
0
 def getFileNamebyID(self, given_fd_id):
     from db_access.config import SQLConn
     sql_con = SQLConn()
     mycursor = sql_con.getSQLConn()
     query = "select fd_file from tbl_feedbackdata where fd_id = '" + str(
         given_fd_id) + "'"
     if mycursor[1].execute(query) != 0:
         a = mycursor[1].fetchall()[0]
         fd_file = a[0]
         mycursor[1].close()
         mycursor[0].close()
         return fd_file
     else:
         print("No Such File Present")
         mycursor[1].close()
         mycursor[0].close()
     return "TD20200502024521.json"
Exemplo n.º 10
0
    def updateTrainingData(self, dataset_id, training_dataset_id):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "update tbl_feedbackdata set td_id =" + training_dataset_id + " where fd_id = " + dataset_id
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 11
0
    def getIDbyFileName(self, given_td_file_name):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        mycursor = sql_con.getSQLConn()
        query = "select td_id from tbl_trainingdata where td_file = '" + str(
            given_td_file_name) + "'"
        if mycursor[1].execute(query) != 0:
            a = mycursor[1].fetchall()[0]
            td_id = a[0]
            mycursor[1].close()
            mycursor[0].close()
            return td_id
        else:
            print("No Such File Present")
            mycursor[1].close()
            mycursor[0].close()

        return 0
Exemplo n.º 12
0
    def updatePwd(self, username_, new_pwd):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "update tbl_users set u_pwd = '" + new_pwd + "' where u_username ='******'"
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 13
0
    def fetch_all_fd(self):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "select fd_id , fd_name, fd_img from tbl_feedbackdata"
        try:
            obj[1].execute(query)
            a = obj[1].fetchall()
            lst = []
            for x in a:
                d = {}
                d['ID'] = x[0]
                d['Name'] = x[1]
                d['Image_URL'] = x[2]
                lst.append(d)

        except:
            print("error in fetching data in fetch_all_fd()")
        return lst
Exemplo n.º 14
0
    def updateImage(self, dataset_id, img_url):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "update tbl_feedbackdata set fd_image = '" + img_url + "' where fd_id =" + str(
            dataset_id)
        # print(query)
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 15
0
 def getData(self, u_name, password):
     from db_access.config import SQLConn
     sql_con = SQLConn()
     mycursor = sql_con.getSQLConn()
     user_obj = UserObj()
     query = 'select * from tbl_users where u_username = "******" and u_pwd = "' + str(password) + '"'
     if mycursor[1].execute(query) != 0:
         a = mycursor[1].fetchall()[0]
         user_obj.username = a[0]
         user_obj.pwd = a[1]
         user_obj.name = a[2]
         user_obj.dept = a[3]
         user_obj.email = a[4]
         user_obj.phone = a[5]
         mycursor[1].close()
         mycursor[0].close()
         return user_obj
     else:
         return False
Exemplo n.º 16
0
    def updateDesc(self, dataset_id, new_desc):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "update tbl_trainingdata set td_desc = '" + new_desc + "' where td_id =" + str(
            dataset_id)
        #print(query)
        try:
            obj[1].execute(query)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 17
0
    def fetch_all_users(self):
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query = "select * from tbl_users"
        try:
            obj[1].execute(query)
            a = obj[1].fetchall()
            lst = []
            for x in a:
                d = {}
                d['Uname'] = x[0]
                d['Pwd'] = x[1]
                d['Name'] = x[2]
                d['Dept'] = x[3]
                d['Email'] = x[4]
                d['Phone'] = x[5]
                lst.append(d)

        except:
            print("error in fetching data in fetch_all_td()")
        #print(lst)
        return lst
Exemplo n.º 18
0
    def updateModel(self, dataset_json_file, new_model, new_accuracy):
        dataset_id = self.getIDbyFileName(dataset_json_file)
        from db_access.config import SQLConn
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        query1 = "update tbl_trainingdata set td_model = '" + str(
            new_model) + "' where td_id =" + str(dataset_id)
        query2 = "update tbl_trainingdata set model_accuracy = '" + str(
            new_accuracy) + "' where td_id =" + str(dataset_id)
        #print(query)
        try:
            obj[1].execute(query1)
            obj[1].execute(query2)
            obj[0].commit()

            return 1
        except:
            obj[0].rollback()
            return 0
        finally:
            obj[1].close()
            obj[0].close()

        return 0
Exemplo n.º 19
0
    def delete_dataset(self, dataset_id, file_path, img_path, result_path,
                       file_name):
        from db_access.config import SQLConn
        import os, re
        sql_con = SQLConn()
        obj = sql_con.getSQLConn()
        if self.getData(dataset_id) != 0:
            if os.path.exists(img_path):
                os.remove(img_path)
            else:
                print("The Image file does not exist")

            if os.path.exists(file_path):
                os.remove(file_path)
            else:
                print("The Feedback file does not exist")

            file_name = re.sub(".json", "", file_name)

            if os.path.exists(result_path + str(file_name) +
                              "_Individual_Comment_Ratings.xlsx"):
                os.remove(result_path + str(file_name) +
                          "_Individual_Comment_Ratings.xlsx")
            else:
                print("The Individual Review (.xlsx) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Individual_Comment_Ratings.csv"):
                os.remove(result_path + str(file_name) +
                          "_Individual_Comment_Ratings.csv")
            else:
                print("The Individual Review (.csv) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Aspect_Based_Analysis.xlsx"):
                os.remove(result_path + str(file_name) +
                          "_Aspect_Based_Analysis.xlsx")
            else:
                print("The Aspect Based Analysis (.xlsx) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Aspect_Based_Analysis.csv"):
                os.remove(result_path + str(file_name) +
                          "_Aspect_Based_Analysis.csv")
            else:
                print("The Aspect Based Analysis (.csv) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Progress_Timeline.xlsx"):
                os.remove(result_path + str(file_name) +
                          "_Progress_Timeline.xlsx")
            else:
                print("The Progress Timeline (.xlsx) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Progress_Timeline.csv"):
                os.remove(result_path + str(file_name) +
                          "_Progress_Timeline.csv")
            else:
                print("The Progress Timeline (.csv) file does not exist")

            if os.path.exists(result_path + str(file_name) +
                              "_Suggestions.json"):
                os.remove(result_path + str(file_name) + "_Suggestions.json")
            else:
                print("The Suggestion (.json) file does not exist")

            if os.path.exists(result_path + str(file_name) + ".json"):
                os.remove(result_path + str(file_name) + ".json")
            else:
                print("The Sentiment rated JSON file (.json) does not exist")

            query = "Delete from tbl_feedbackdata where fd_id =" + str(
                dataset_id)

            try:
                obj[1].execute(query)
                obj[0].commit()

                return 1
            except:
                obj[0].rollback()
                return 0
            finally:
                obj[1].close()
                obj[0].close()
        else:
            print("No Such Dataset to Delete")
        return 0