def Handle_LogIn(self):
        print("button pressed")
        db = DatabaseManager(self.db_file_loc, self.protected_table_prefix)
        username = self.user_name_tf.text()
        password = self.password_tf.text()

        try:
            if db.is_valid_string(username) and db.is_valid_string(password):
                #Both user name and password have to be valid strings to continue
                if not db.doesTableExist(self.account_info_table_name):
                    print("Must create account before")

                #Gets the account from the databse with the same password
                #If the isn't a match then it returns none
                row_with_entered_pass = db.get_row_at(
                    self.account_info_table_name,
                    column_name=account_columns[0],
                    column_value=password)
                #                 print(row_with_entered_pass)

                if not row_with_entered_pass == None:
                    #If the there is a password match then save the info
                    password_db = row_with_entered_pass[0]
                    user_name_db = row_with_entered_pass[1]

                    if password_db == password and user_name_db == username:
                        #If the user name and password entered match the
                        #user name and password in the db then it's a valid login
                        self.valid_login()
                    else:
                        ErrorBox = QtWidgets.QMessageBox()
                        ErrorBox.warning(
                            self, 'No Account Found',
                            "No account found for the combination of user name and password",
                            ErrorBox.Ok)

                else:
                    ErrorBox = QtWidgets.QMessageBox()
                    ErrorBox.warning(
                        self, 'No Account Found',
                        "No account found for the combination of user name and password",
                        ErrorBox.Ok)
            else:
                raise Exception()
        except:
            ErrorBox = QtWidgets.QMessageBox()
            ErrorBox.critical(
                self, 'Text Entry Error',
                "Text entries can only have letters numbers, and underscores",
                ErrorBox.Ok)
Пример #2
0
    def create_account_closed(self, new_account_info):
        #Info comes in as first name, last name, user name, password
        print(new_account_info)

        temp = new_account_info.split('//')

        reformated_data = ([0] * 4)
        reformated_data[0] = temp[1]
        reformated_data[1] = temp[0]
        reformated_data[2] = temp[2]
        reformated_data[3] = temp[3]

        db = DatabaseManager(self.db_file_loc, self.protected_table_prefix)

        if not db.doesTableExist(self.account_info_table_name):
            db.create_table_list(self.account_info_table_name, account_columns,
                                 'string')

        db.add_row_list(self.account_info_table_name, account_columns,
                        reformated_data)

        self.show()
class Ui_CalendarForm(QtWidgets.QDialog):

    calendar_to_lists_signal = QtCore.pyqtSignal()
    calendar_to_login_signal = QtCore.pyqtSignal()

    def __init__(self, db_file, protected_table_prefix):
        try:
            super().__init__()
            self.setupUi()
            # for the table
            self.protected_table_prefix = protected_table_prefix
            self.db = DatabaseManager(db_file, self.protected_table_prefix)
            self.db_file_loc = db_file
            self.event_info_table_name = protected_table_prefix + "Event_Information"
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    # creates method that handles the add event button and opens the dialog window
    def EventButton_handler(self):
        try:
            self.ui_update = Ui_Dialog('programData.db', '__ADMIN__')
            self.ui_update.calendar_dialog_signal.connect(self.offpass)
            self.ui_update.exec_()
        except Exception as er:
            print('Error message:', er.args[0])
            return False
        #self.calendar.

    #passes
    def offpass(self):
        pass

    # creates method that handles lists page button and changes widget to the show lists page
    def handle_listsPageButton(self):
        self.calendar_to_lists_signal.emit()

    # creates method that handles the profile page button and it opens the profile page
    def handle_profilePageButton(self):
        try:
            self.createProfileWidget = UI_ProfilePage()
            self.createProfileWidget.create_account_done_signal.connect()
            self.createProfileWidget.exec_()
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    # creates method that handles the search page button and it should open the show list ui page
    def handle_searchPageButton(self):
        try:
            self.calendar_to_login_signal.emit()
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    # creates method that handles the home page button and it just refreshes the page
    def handle_homePageButton(self):
        self.update()

    # creates a method that sets the label on the page to the date that is selected from the calendar
    def showDate(self, date):
        try:
            dater = date.toString("MM-dd-yy")
            self.label.setText(dater)
            if not self.db.doesTableExist(self.event_info_table_name):
                self.label_3.setText('No events')
            row = self.db.get_row_at(self.event_info_table_name,
                                     Event_Columns[0], dater)
            if not row == None:
                self.label_3.setText(row[1])
            else:
                self.label_3.setText('No events')
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    def setupUi(self):
        # auto generated code from Qt Designer, creates all elements of the page
        try:
            self.setObjectName("CalendarForm")
            self.setEnabled(True)
            self.resize(1650, 950)
            self.setLayoutDirection(QtCore.Qt.LeftToRight)
            self.setAutoFillBackground(True)
            self.CompNameLabel = QtWidgets.QLabel(self)
            self.CompNameLabel.setGeometry(QtCore.QRect(0, 0, 300, 75))
            font = QtGui.QFont()
            font.setFamily("MS Shell Dlg 2")
            font.setPointSize(16)
            font.setBold(True)
            font.setItalic(False)
            font.setWeight(75)
            self.CompNameLabel.setFont(font)
            self.CompNameLabel.setAutoFillBackground(True)
            self.CompNameLabel.setFrameShape(QtWidgets.QFrame.NoFrame)
            self.CompNameLabel.setFrameShadow(QtWidgets.QFrame.Plain)
            self.CompNameLabel.setTextFormat(QtCore.Qt.AutoText)
            self.CompNameLabel.setScaledContents(False)
            self.CompNameLabel.setAlignment(QtCore.Qt.AlignCenter)
            self.CompNameLabel.setWordWrap(False)
            self.CompNameLabel.setObjectName("CompNameLabel")
            self.calendar = QtWidgets.QCalendarWidget(self)
            self.calendar.setGeometry(QtCore.QRect(75, 175, 750, 700))
            font = QtGui.QFont()
            font.setFamily("MS Shell Dlg 2")
            font.setPointSize(8)
            font.setBold(False)
            font.setItalic(False)
            font.setUnderline(False)
            font.setWeight(50)
            font.setStrikeOut(False)
            font.setKerning(True)
            self.calendar.setFont(font)
            self.calendar.setLayoutDirection(QtCore.Qt.LeftToRight)
            self.calendar.setAutoFillBackground(True)
            self.calendar.setFirstDayOfWeek(QtCore.Qt.Sunday)
            self.calendar.setGridVisible(True)
            self.calendar.setSelectionMode(
                QtWidgets.QCalendarWidget.SingleSelection)
            self.calendar.setHorizontalHeaderFormat(
                QtWidgets.QCalendarWidget.LongDayNames)
            self.calendar.setVerticalHeaderFormat(
                QtWidgets.QCalendarWidget.NoVerticalHeader)
            self.calendar.setNavigationBarVisible(True)
            self.calendar.setDateEditEnabled(True)
            self.calendar.setObjectName("calendar")
            self.horizontalLayoutWidget = QtWidgets.QWidget(self)
            self.horizontalLayoutWidget.setGeometry(
                QtCore.QRect(1410, 100, 160, 80))
            self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
            self.horizontalLayout = QtWidgets.QHBoxLayout(
                self.horizontalLayoutWidget)
            self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
            self.horizontalLayout.setObjectName("horizontalLayout")
            self.EventButton = QtWidgets.QPushButton(
                self.horizontalLayoutWidget)
            self.EventButton.setIconSize(QtCore.QSize(20, 20))
            self.EventButton.setCheckable(False)
            self.EventButton.setAutoRepeat(False)
            self.EventButton.setAutoDefault(False)
            self.EventButton.setFlat(False)
            self.EventButton.setObjectName("EventButton")
            self.horizontalLayout.addWidget(self.EventButton)
            self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self)
            self.horizontalLayoutWidget_2.setGeometry(
                QtCore.QRect(1110, 0, 461, 76))
            self.horizontalLayoutWidget_2.setObjectName(
                "horizontalLayoutWidget_2")
            self.horizontalLayout_2 = QtWidgets.QHBoxLayout(
                self.horizontalLayoutWidget_2)
            self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
            self.horizontalLayout_2.setObjectName("horizontalLayout_2")
            self.HomePageButton = QtWidgets.QPushButton(
                self.horizontalLayoutWidget_2)
            self.HomePageButton.setObjectName("HomePageButton")
            self.horizontalLayout_2.addWidget(self.HomePageButton)
            self.ListsPageButton = QtWidgets.QPushButton(
                self.horizontalLayoutWidget_2)
            self.ListsPageButton.setObjectName("ListsPageButton")
            self.horizontalLayout_2.addWidget(self.ListsPageButton)
            self.SearchPageButton = QtWidgets.QPushButton(
                self.horizontalLayoutWidget_2)
            self.SearchPageButton.setObjectName("SearchPageButton")
            self.horizontalLayout_2.addWidget(self.SearchPageButton)
            self.label = QtWidgets.QLabel(self)
            self.label.setGeometry(QtCore.QRect(975, 159, 150, 50))
            font = QtGui.QFont()
            font.setPointSize(22)
            font.setBold(True)
            font.setWeight(75)
            self.label.setFont(font)
            self.label.setAutoFillBackground(False)
            self.label.setObjectName("label")
            self.label_2 = QtWidgets.QLabel(self)
            self.label_2.setGeometry(QtCore.QRect(875, 134, 300, 100))
            font = QtGui.QFont()
            font.setPointSize(20)
            font.setBold(True)
            font.setUnderline(True)
            font.setWeight(75)
            self.label_2.setFont(font)
            self.label_2.setAutoFillBackground(False)
            self.label_2.setObjectName("label_2")
            self.label_3 = QtWidgets.QTextBrowser(self)
            self.label_3.setGeometry(QtCore.QRect(875, 250, 700, 625))
            self.label_3.setAutoFillBackground(False)
            self.label_3.setAlignment(QtCore.Qt.AlignTop)
            self.label_3.setObjectName("label_3")
            self.label_3.setFontPointSize(20)
            self.label_4 = QtWidgets.QLabel(self)
            self.label_4.setGeometry(QtCore.QRect(925, 775, 100, 50))
            font = QtGui.QFont()
            font.setBold(False)
            font.setUnderline(True)
            font.setWeight(50)
            self.label_4.setFont(font)
            self.label_4.setAutoFillBackground(False)
            self.label_4.setObjectName("label_4")
            self.label_5 = QtWidgets.QLabel(self)
            self.label_5.setGeometry(QtCore.QRect(925, 825, 100, 50))
            font = QtGui.QFont()
            font.setUnderline(True)
            self.label_5.setFont(font)
            self.label_5.setAutoFillBackground(False)
            self.label_5.setObjectName("label_5")
            self.line = QtWidgets.QFrame(self)
            self.line.setGeometry(QtCore.QRect(10, 75, 1630, 20))
            self.line.setFrameShape(QtWidgets.QFrame.HLine)
            self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
            self.line.setObjectName("line")

            self.retranslateUi()

            # these lines create connects to the buttons with there corresponding methods
            self.calendar.clicked[QtCore.QDate].connect(self.showDate)
            date = self.calendar.selectedDate()
            self.ListsPageButton.clicked.connect(self.handle_listsPageButton)
            self.SearchPageButton.clicked.connect(self.handle_searchPageButton)
            self.HomePageButton.clicked.connect(self.handle_homePageButton)
            self.EventButton.clicked.connect(self.EventButton_handler)
            QtCore.QMetaObject.connectSlotsByName(self)
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    # code that is auto generated from Qt Designer
    def retranslateUi(self):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("CalendarForm", "Calendar"))
        self.CompNameLabel.setText(
            _translate("CalendarForm", "Chicago Turnkey Properties"))
        self.EventButton.setText(_translate("CalendarForm", "Add Event"))
        self.HomePageButton.setText(_translate("CalendarForm", "Home"))
        self.ListsPageButton.setText(_translate("CalendarForm", "Leads Page"))
        self.SearchPageButton.setText(_translate("CalendarForm", "Sign out"))
        self.label.setText(_translate("CalendarForm", ""))
        self.label_2.setText(_translate("CalendarForm", "Event:"))
        self.label_3.setText(_translate("CalendarForm", " "))
        self.label_4.setText(_translate("CalendarForm", ""))
        self.label_5.setText(_translate("CalendarForm", ""))
Пример #4
0
class Ui_Dialog(QtWidgets.QDialog):

    calendar_dialog_signal = QtCore.pyqtSignal()

    def __init__(self, db_file, protected_table_prefix):
        try:
            super().__init__()
            self.setupUi()
            self.protected_table_prefix = protected_table_prefix
            self.db = DatabaseManager(db_file, self.protected_table_prefix)
            self.db_file_loc = db_file
            self.event_info_table_name = protected_table_prefix + "Event_Information"
        except Exception as er:
            print('Error message:', er.args[0])
            return None

    # creates method for the ok button that creates variables holding the date and event text typed by the user
    # it will also save the information into the table
    def handle_acceptClick(self):
        eventDate = self.DateLineEdit.text()
        eventEdit = self.textEdit.toPlainText()
        #         print(eventDate)
        #print(eventEdit)
        event_data = ([0] * 4)
        event_data[0] = eventDate
        event_data[1] = eventEdit
        event_data[2] = ""
        event_data[3] = ""
        # database stuff
        try:
            if not self.db.doesTableExist(self.event_info_table_name):
                self.db.create_table_list(self.event_info_table_name,
                                          Event_Columns, 'string')
            self.db.add_row_list(self.event_info_table_name, Event_Columns,
                                 event_data)
            self.calendar_dialog_signal.emit()
            self.close()
        except Exception as er:
            print('Error message:', er.args[0])
            return False

    # creates method for the cancel button that closes the dialog and leaves the calendar widget open
    def handle_rejectClick(self):
        self.close()

    # creates method for the add address button for the dialog and opens something to add an address for the event
    def handle_addAddressButton(self):
        self.close()

    # creates method for the add group button for the dialog and opens something to add a group for the event
    def handle_addGroupButton(self):
        self.close()

    # auto generated code from Qt Designer that creates all the entities for the calendar dialog and their parameters
    def setupUi(self):
        self.setObjectName("Dialog")
        self.resize(350, 400)
        self.setAutoFillBackground(True)
        self.DateLabel = QtWidgets.QLabel(self)
        self.DateLabel.setGeometry(QtCore.QRect(20, 20, 50, 25))
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.DateLabel.setFont(font)
        self.DateLabel.setObjectName("DateLabel")
        self.EventLabel = QtWidgets.QLabel(self)
        self.EventLabel.setGeometry(QtCore.QRect(20, 60, 50, 25))
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.EventLabel.setFont(font)
        self.EventLabel.setObjectName("EventLabel")
        self.DateLineEdit = QtWidgets.QLineEdit(self)
        self.DateLineEdit.setGeometry(QtCore.QRect(80, 20, 200, 25))
        self.DateLineEdit.setObjectName("DateLineEdit")
        self.AddAddressButton = QtWidgets.QPushButton(self)
        self.AddAddressButton.setGeometry(QtCore.QRect(20, 305, 75, 25))
        self.AddAddressButton.setObjectName("AddAddressButton")
        self.AddGroupButton = QtWidgets.QPushButton(self)
        self.AddGroupButton.setGeometry(QtCore.QRect(180, 305, 75, 25))
        self.AddGroupButton.setObjectName("AddGroupButton")
        self.AddressLabel = QtWidgets.QLabel(self)
        self.AddressLabel.setGeometry(QtCore.QRect(105, 305, 75, 25))
        self.AddressLabel.setObjectName("AddressLabel")
        self.GroupLabel = QtWidgets.QLabel(self)
        self.GroupLabel.setGeometry(QtCore.QRect(260, 305, 75, 25))
        self.GroupLabel.setObjectName("GroupLabel")
        self.ExampleLabel = QtWidgets.QLabel(self)
        self.ExampleLabel.setGeometry(QtCore.QRect(80, 50, 115, 13))
        self.ExampleLabel.setObjectName("ExampleLabel")
        self.CancelButton = QtWidgets.QPushButton(self)
        self.CancelButton.setGeometry(QtCore.QRect(260, 360, 75, 25))
        self.CancelButton.setObjectName("CancelButton")
        self.OkButton = QtWidgets.QPushButton(self)
        self.OkButton.setGeometry(QtCore.QRect(180, 360, 75, 25))
        self.OkButton.setObjectName("OkButton")
        self.textEdit = QtWidgets.QTextEdit(self)
        self.textEdit.setGeometry(QtCore.QRect(20, 95, 260, 200))
        self.textEdit.setObjectName("textEdit")

        self.retranslateUi()

        # creates the signal for the ok and reject buttons and connects them with their corresponding functions
        self.OkButton.clicked.connect(self.handle_acceptClick)
        self.CancelButton.clicked.connect(self.handle_rejectClick)
        self.AddAddressButton.clicked.connect(self.handle_addAddressButton)
        self.AddGroupButton.clicked.connect(self.handle_addGroupButton)
        QtCore.QMetaObject.connectSlotsByName(self)

    # auto generated code from Qt Designer
    def retranslateUi(self):
        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("Dialog", "Dialog"))
        self.DateLabel.setText(_translate("Dialog", "Date"))
        self.EventLabel.setText(_translate("Dialog", "Event"))
        self.AddAddressButton.setText(_translate("Dialog", "Add Address"))
        self.AddGroupButton.setText(_translate("Dialog", "Add Group"))
        self.AddressLabel.setText(_translate("Dialog", "None"))
        self.GroupLabel.setText(_translate("Dialog", "None"))
        self.ExampleLabel.setText(_translate("Dialog", "Example: MM-DD-YY"))
        self.CancelButton.setText(_translate("Dialog", "Cancel"))
        self.OkButton.setText(_translate("Dialog", "OK"))
class csv_importer_popup(QtWidgets.QDialog):
    #Signals when csv_importer_popup closes
    importDoneSignal = QtCore.pyqtSignal('QString')

    def __init__(self, window_title, db_file_loc, tables,
                 protected_table_prefix):
        super().__init__()
        #Creating the window
        self.title = window_title
        self.setWindowTitle(self.title)
        self.protected_table_prefix = protected_table_prefix
        self.tablesInDB = tables
        #Database manager stuff
        self.db = DatabaseManager(db_file_loc, protected_table_prefix)

        #Create array with tables already in the database to be
        #put in the common files radio button box
        self.default_lists = []
        for table in tables:
            tempList = []
            for columnName in self.db.get_headers(table):
                tempList.append(columnName)
            self.default_lists.append(tempList)

        self.layout = QGridLayout()

    def run_popup(self, file_loc):
        #CSV file stuff
        self.ingestor = Ingestor(file_loc)
        self.ingestor.readCSV()

        self.rows = self.ingestor.getCSVHeaders()

        #Create buttons from the csv file headers that was just selected
        self.generate_checkboxes(self.rows)

        #Create a area that has a scroll bar
        scrollArea = QScrollArea()
        scrollArea.setWidget(self.csvHeaderGroup_box)
        scrollArea.horizontalScrollBar().setEnabled(False)

        #Create the buttons for tables that already exist in the database
        self.generate_radiobuttons(self.tablesInDB)

        #List of button groups
        self.buttonGroups = [self.commonFileTypesGroup, self.csvHeaderGroup]

        #Create label
        tableNameLabel = QtWidgets.QLabel("Table Name")

        #Create text field
        self.tableNameField = QtWidgets.QLineEdit()
        self.tableNameField.setPlaceholderText("Enter Custom Table Name")

        #Create buttons
        self.cancelButton = QPushButton('Cancel')
        self.importButton = QPushButton('Import')

        self.cancelButton.clicked.connect(self.closeWindow)
        self.importButton.clicked.connect(self.importCSV)

        #Create progress Bar
        self.progressBar = QtWidgets.QProgressBar()

        #Create the master layout which is a grid
        layout = QGridLayout()
        #Add widgets
        #format of addWidget(widget,row,col,row span, col span)
        layout.addWidget(scrollArea, 1, 1, 1, 2)
        layout.addWidget(tableNameLabel, 2, 1, 1, 2)
        layout.addWidget(self.tableNameField, 3, 1, 1, 2)
        layout.addWidget(self.commonFileTypesGroupBox, 4, 1, 1, 2)
        layout.addWidget(self.progressBar, 5, 1, 1, 2)
        layout.addWidget(self.cancelButton, 6, 1)
        layout.addWidget(self.importButton, 6, 2)
        self.setLayout(layout)
        self.resize(self.sizeHint())

    def generate_checkboxes(self, button_name_list):
        #Generate check_boxes
        self.csvHeaderGroup = QButtonGroup()
        self.csvHeaderGroup_layout = QVBoxLayout()
        self.csvHeaderGroup.setExclusive(False)
        self.csvHeaderGroup_box = QGroupBox('Select which headers')
        self.csvHeaderGroup_layout.addStretch(1)
        for button_name in button_name_list:
            #Add each button to the layout from the csv file
            checkbox = QCheckBox(button_name)
            self.csvHeaderGroup.addButton(checkbox)
            self.csvHeaderGroup_layout.addWidget(
                self.csvHeaderGroup.buttons()[-1])

        self.csvHeaderGroup_box.setLayout(self.csvHeaderGroup_layout)

    def generate_radiobuttons(self, button_name_list):
        #Generate Radio Buttons
        self.commonFileTypesGroup = QButtonGroup()
        self.commonFileTypesGroupLayout = QVBoxLayout()
        self.commonFileTypesGroupBox = QGroupBox('Select a pre-existing table')
        self.commonFileTypesGroupLayout.addStretch(1)
        count = 0
        for button_name in button_name_list:
            #Add each button from available lists in database
            radioButton = QRadioButton(button_name)
            self.commonFileTypesGroup.addButton(radioButton, count)
            self.commonFileTypesGroupLayout.addWidget(
                self.commonFileTypesGroup.buttons()[-1])
            count += 1

        self.commonFileTypesGroupBox.setLayout(self.commonFileTypesGroupLayout)

    def import_done(self, tableName):
        #Returns what table was created
        self.importDoneSignal.emit(tableName)
        self.accept()

    def closeWindow(self):
        #Closes the window
        self.reject()

    def importCSV(self):
        self.importButton.setEnabled(False)
        self.cancelButton.setEnabled(False)
        #Check if any radio buttons were pressed by checking if they were
        #checked and save the number in the button group
        radio_button_number = -1
        special_button_number = -1
        count = 0
        for radioButton in self.buttonGroups[0].buttons():
            if radioButton.isChecked():
                radio_button_number = count
                break
            count += 1
        for specialButton in self.buttonGroups[1].buttons(
        ):  # Do the same for the special buttons
            if specialButton.isChecked():
                special_button_number = count
                break
            count += 1

        if radio_button_number > -1:
            searchCritera = self.ingestor.getHeaderIndex(
                self.default_lists[radio_button_number],
                self.ingestor.getCSVHeaders())
            buttonText = self.buttonGroups[0].buttons(
            )[radio_button_number].text()
            #Check which table corresponds with the button pressed

            for tableName in self.tablesInDB:
                if buttonText.replace(' ', '_') == tableName:

                    #Uses the ingestor to search the un-filtered rows using
                    #this search criteria list

                    self.ingestor.searchRows(searchCritera,
                                             self.ingestor.getRows())
                    #Check if tables exists already
                    if not self.db.doesTableExist(tableName):
                        #If not the create it with the table name
                        self.db.create_table_list(
                            tableName,
                            self.db.remove_spaces(
                                self.default_lists[radio_button_number]),
                            'string')

                    self.import_with_progress_bar(
                        tableName, self.ingestor.getRows(),
                        self.default_lists[radio_button_number])
                    self.import_done(tableName)
        else:
            try:
                if self.tableNameField.text(
                ) == '' or self.protected_table_prefix in self.tableNameField.text(
                ):
                    raise Exception()
                else:
                    customTableName = self.db.is_valid_string(
                        self.tableNameField.text().replace(' ', '_'))
                    if special_button_number > -1:
                        # Default header option not chosen, so custom lists
                        try:
                            requestedHeaders = []
                            for item in self.buttonGroups[1].buttons():
                                if item.isChecked():
                                    requestedHeaders.append(item.text())

                            does_exist = self.db.doesTableExist(
                                customTableName)
                            has_same_cols = True
                            if not does_exist:
                                #If not the create it with the table name
                                self.db.create_table_list(
                                    customTableName,
                                    self.db.remove_spaces(requestedHeaders),
                                    'string')
                            else:
                                #Tables exists. Does it have the same columns?
                                if not (requestedHeaders ==
                                        self.db.get_headers(customTableName)):
                                    has_same_cols = False
                                    #Find the different column names
                                    #This works by turning the lists into sets
                                    #A set is an unordered list with no duplicate elements
                                    #A set supports matrix operations so you can subtract the two sets
                                    #This returns the elements that are not shared
                                    different_cols = list(
                                        set(
                                            self.db.remove_spaces(
                                                requestedHeaders)) - set(
                                                    self.db.get_headers(
                                                        customTableName)))
                                    #Add the extra columns
                                    for col in different_cols:
                                        self.db.add_column(
                                            customTableName, col, 'string')

                            if has_same_cols:
                                #New table is identical to existing one
                                print("same columns")
                                searchCritera = self.ingestor.getHeaderIndex(
                                    requestedHeaders,
                                    self.ingestor.getCSVHeaders())
                                self.ingestor.searchRows(
                                    searchCritera, self.ingestor.getRows())
                                rows = self.ingestor.getRows()
                                self.import_with_progress_bar(
                                    customTableName, self.ingestor.getRows(),
                                    requestedHeaders)
                            else:
                                #New table has different columns
                                #Combine the headers in the lists
                                print("diff columns")
                                combinedHeaders = self.db.get_headers(
                                    customTableName) + requestedHeaders
                                #Have to re order them to match the csv file
                                newRequestedHeaders = []
                                for header in self.db.remove_spaces(
                                        self.ingestor.getCSVHeaders()):
                                    #Find the header in the csv file
                                    #The order matters because the primary key is needed to update the row
                                    if header in combinedHeaders:
                                        newRequestedHeaders.append(header)

                                #Get the index for the header
                                searchCritera = self.ingestor.getHeaderIndex(
                                    newRequestedHeaders,
                                    self.ingestor.getCSVHeaders())
                                #Filter the rows so only the requested info is there
                                self.ingestor.searchRows(
                                    searchCritera, self.ingestor.getRows())
                                rows = self.ingestor.getRows()
                                #Import them nomrally
                                self.import_with_progress_bar(
                                    customTableName, self.ingestor.getRows(),
                                    newRequestedHeaders)

                            self.import_done(customTableName)
                        except Exception as er:
                            #General error message
                            print('Error message:', er.args[0])
                            return False
                    else:
                        raise Exception()

            except:
                ErrorBox = QtWidgets.QMessageBox()
                choice = ErrorBox.critical(
                    self, 'Table Name Error',
                    "Table name can only have letters numbers, and underscores",
                    ErrorBox.Ok)
                if choice == ErrorBox.Ok:
                    #User wants to try a new name
                    print("Closing")
                    ErrorBox.accept()
                    self.importButton.setEnabled(True)
                    self.cancelButton.setEnabled(True)

    def import_with_progress_bar(self, tableName, rows_to_be_added,
                                 column_headers):
        """
        Adds the ingestor rows to the db one row at a time so the progress
        bar will show the progress
        """
        #Set the max value of the progress bar to the number of rows to be add

        self.progressBar.setMaximum(len(rows_to_be_added))
        #self.db.add_list_of_rows(tableName,self.db.remove_spaces(self.default_lists[button_number]),rows)
        count = 0
        for row in rows_to_be_added:
            #For every row to be added add it to the db and increment the progress
            #bar value by 1
            count += 1
            self.db.add_row_list(tableName,
                                 self.db.remove_spaces(column_headers), row)
            self.progressBar.setValue(count)