Ejemplo n.º 1
0
 def executeevent(self):
     se=self.selectentry.text()
     fe=self.fromentry.text()
     we=self.whereentry.text()
     gbe=self.groupbyentry.text()
     if we=="":
         QMessageBox.about(self, "Alert", "Fill all required entries.")
     elif se=="":
         QMessageBox.about(self, "Alert", "Fill all required entries.")
     elif fe=="":
         QMessageBox.about(self, "Alert", "Fill all required entries.")
     elif gbe=="":
         QMessageBox.about(self, "Alert", "Fill all required entries.")
     else:
         if we=="-":
             query="SELECT "+se+" FROM "+fe+" GROUP BY "+gbe+";"
         else:
             query="SELECT "+se+" FROM "+fe+" WHERE "+we+" GROUP BY "+gbe+";"
         cn=sqlite3.connect(self.dbname+'.db')
         crob=cn.cursor()
         crob.execute(query)
         result=crob.fetchall()
         cn.commit()
         cn.close()
             
         self.window = QtWidgets.QMainWindow()
         self.ui = Ui_display()
         self.ui.setupUi(self.window,result)
         self.window.show()
         self.groupbyclause.close()
Ejemplo n.º 2
0
    def executeevent(self):
        se = self.selectentry.text()
        fe = self.fromentry.text()
        le = self.limitentry.text()
        if le == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif se == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif fe == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        else:
            query = "SELECT " + se + " FROM " + fe + " LIMIT " + le + ";"
            cn = sqlite3.connect(self.dbname + '.db')
            crob = cn.cursor()
            crob.execute(query)
            result = crob.fetchall()
            cn.commit()
            cn.close()

            self.window = QtWidgets.QMainWindow()
            self.ui = Ui_display()
            self.ui.setupUi(self.window, result)
            self.window.show()
            self.limitclause.close()
Ejemplo n.º 3
0
class Ui_limitclause(QWidget):
    dbname = ""
    limitclause = None

    def setupUi(self, limitclause, dbname):
        limitclause.setObjectName("limitclause")
        limitclause.resize(454, 222)
        limitclause.setStyleSheet("background-color: rgb(255, 255, 191);")
        self.centralwidget = QtWidgets.QWidget(limitclause)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 0, 431, 161))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.fromentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.fromentry.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                     "font: 10pt \"Comic Sans MS\";")
        self.fromentry.setObjectName("fromentry")
        self.gridLayout.addWidget(self.fromentry, 1, 2, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.gridLayoutWidget)
        self.label_2.setStyleSheet("font: 10pt \"Comic Sans MS\";")
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
        self.label = QtWidgets.QLabel(self.gridLayoutWidget)
        self.label.setStyleSheet("font: 10pt \"Comic Sans MS\";")
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
        self.selectentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.selectentry.setStyleSheet(
            "background-color: rgb(255, 255, 255);\n"
            "font: 10pt \"Comic Sans MS\";")
        self.selectentry.setObjectName("selectentry")
        self.gridLayout.addWidget(self.selectentry, 0, 2, 1, 1)
        self.limitentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.limitentry.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                      "font: 10pt \"Comic Sans MS\";")
        self.limitentry.setObjectName("limitentry")
        self.gridLayout.addWidget(self.limitentry, 2, 2, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(40, 20,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
        self.label_4 = QtWidgets.QLabel(self.gridLayoutWidget)
        self.label_4.setStyleSheet("font: 10pt \"Comic Sans MS\";")
        self.label_4.setObjectName("label_4")
        self.gridLayout.addWidget(self.label_4, 2, 0, 1, 1)
        self.execute = QtWidgets.QPushButton(self.centralwidget)
        self.execute.setGeometry(QtCore.QRect(10, 190, 75, 23))
        self.execute.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                   "font: 10pt \"Comic Sans MS\";")
        self.execute.setObjectName("execute")
        self.reset = QtWidgets.QPushButton(self.centralwidget)
        self.reset.setGeometry(QtCore.QRect(370, 190, 75, 23))
        self.reset.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                 "font: 10pt \"Comic Sans MS\";")
        self.reset.setObjectName("reset")
        self.line = QtWidgets.QFrame(self.centralwidget)
        self.line.setGeometry(QtCore.QRect(10, 160, 431, 20))
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        limitclause.setCentralWidget(self.centralwidget)

        self.retranslateUi(limitclause)
        QtCore.QMetaObject.connectSlotsByName(limitclause)
        limitclause.setFixedSize(454, 222)

        self.limitclause = limitclause
        self.dbname = dbname
        self.selectentry.setFocus()

        self.reset.clicked.connect(self.resetevent)
        self.execute.clicked.connect(self.executeevent)

    def resetevent(self):
        self.selectentry.setText("")
        self.fromentry.setText("")
        self.limitentry.setText("")
        self.selectentry.setFocus()

    def executeevent(self):
        se = self.selectentry.text()
        fe = self.fromentry.text()
        le = self.limitentry.text()
        if le == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif se == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif fe == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        else:
            query = "SELECT " + se + " FROM " + fe + " LIMIT " + le + ";"
            cn = sqlite3.connect(self.dbname + '.db')
            crob = cn.cursor()
            crob.execute(query)
            result = crob.fetchall()
            cn.commit()
            cn.close()

            self.window = QtWidgets.QMainWindow()
            self.ui = Ui_display()
            self.ui.setupUi(self.window, result)
            self.window.show()
            self.limitclause.close()

    def retranslateUi(self, limitclause):
        _translate = QtCore.QCoreApplication.translate
        limitclause.setWindowTitle(_translate("limitclause", "LIMIT"))
        self.label_2.setText(_translate("limitclause", "FROM"))
        self.label.setText(_translate("limitclause", "SELECT"))
        self.label_4.setText(_translate("limitclause", "LIMIT"))
        self.execute.setText(_translate("limitclause", "Execute"))
        self.reset.setText(_translate("limitclause", "Reset"))
Ejemplo n.º 4
0
    def execevent(self):
        sw = ''
        fw = ''
        query = str(self.query.toPlainText())
        query = query.strip()
        query1 = query.lower()
        f = 0
        q = ''
        count = 0
        cn = sqlite3.connect(self.dbname + '.db')
        crob = cn.cursor()
        try:
            crob.execute(query)
        except:
            f = 1
            QMessageBox.about(self, "Alert", "Some Error Occured.")
        cn.commit()
        cn.close()
        if f == 0:
            QMessageBox.about(self, "Message",
                              "Database Action Successfully Executed.")
            self.query.setText("")
            self.query.setFocus()
            for ch in query1:
                if ch != ' ':
                    q = q + ch
                else:
                    count += 1
                    if count == 1:
                        fw = q
                        q = q + ' '
                    if count == 2:
                        sw = q
                        break

            if sw == 'create table':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('table') + 6
                end = query1.index('(')
                tn = query[start:end]
                crob.execute(
                    "INSERT INTO TName(tname,dbname,query)VALUES(?,?,?);",
                    (tn, self.dbname, query))
                cn.commit()
                cn.close()

            elif sw == 'drop table':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('table') + 6
                tn = query[start:]
                crob.execute("DELETE FROM TName WHERE tname=? AND dbname=?;",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'create view':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('view') + 5
                end = query1.index('as') - 1
                tn = query[start:end]
                crob.execute("INSERT INTO VName(vname,dbname)VALUES(?,?);",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'drop view':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('view') + 5
                tn = query[start:]
                crob.execute("DELETE FROM VName WHERE vname=? AND dbname=?;",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'alter table':
                if query1.find('rename') > -1:
                    start = query1.index('table') + 6
                    end = query1.index('rename') - 1
                    tn = query[start:end]
                    start = query1.index('to') + 3
                    ntn = query[start:]
                    cn = sqlite3.connect('sqlgenerator.db')
                    crob = cn.cursor()
                    crob.execute("SELECT * FROM TName")
                    record = crob.fetchall()
                    for entry in record:
                        tname = str(entry[0])
                        dbn = str(entry[1])
                        if tname == tn and dbn == self.dbname:
                            q = str(entry[2])
                    crob.execute(
                        "UPDATE TName SET tname=? WHERE dbname=? AND query=?;",
                        (ntn, self.dbname, q))
                    cn.commit()
                    cn.close()
                    start = q.index('(')
                    qu = q[start:]
                    q = "CREATE TABLE " + ntn + qu
                    cn = sqlite3.connect('sqlgenerator.db')
                    crob = cn.cursor()
                    crob.execute(
                        "UPDATE TName SET query=? WHERE tname=? AND dbname=?;",
                        (q, ntn, self.dbname))
                    cn.commit()
                    cn.close()

                if query1.find('add') > -1:
                    start = query1.index('table') + 6
                    end = query1.index('add') - 1
                    tn = query[start:end]
                    cn = sqlite3.connect(self.dbname + '.db')
                    crob = cn.cursor()
                    sql = "SELECT sql FROM sqlite_master WHERE name='" + tn + "';"
                    crob.execute(sql)
                    result = crob.fetchone()
                    for record in result:
                        print(record)
                        cn1 = sqlite3.connect('sqlgenerator.db')
                        crob1 = cn1.cursor()
                        crob1.execute(
                            "UPDATE TName SET query=? WHERE tname=? AND dbname=?",
                            (record, tn, self.dbname))
                        cn1.commit()
                        cn1.close()
                    cn.commit()
                    cn.close()

            elif fw == 'select':
                cn = sqlite3.connect(self.dbname + '.db')
                crob = cn.cursor()
                crob.execute(query)
                result = crob.fetchall()
                cn.commit()
                cn.close()

                self.window = QtWidgets.QMainWindow()
                self.ui = Ui_display()
                self.ui.setupUi(self.window, result)
                self.window.show()
                self.querybrowser.close()

            elif fw == 'insert' or fw == 'delete' or fw == 'update':
                f = 0

            else:
                QMessageBox.about(
                    self, "Alert",
                    "Action NOT supported by the Application. \nThis modification may not be seen in the application."
                )
Ejemplo n.º 5
0
class Ui_querybrowser(QWidget):
    dbname = ''
    querybrowser = None

    def setupUi(self, querybrowser, dn):
        querybrowser.setObjectName("querybrowser")
        querybrowser.resize(536, 282)
        querybrowser.setStyleSheet("background-color: rgb(218, 218, 218);\n"
                                   "")
        self.centralwidget = QtWidgets.QWidget(querybrowser)
        self.centralwidget.setObjectName("centralwidget")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(10, 10, 111, 31))
        font = QtGui.QFont()
        font.setFamily("Comic Sans MS")
        font.setPointSize(12)
        font.setBold(True)
        font.setItalic(False)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.query = QtWidgets.QTextEdit(self.centralwidget)
        self.query.setGeometry(QtCore.QRect(20, 50, 491, 151))
        self.query.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                 "font: 9pt \"Comic Sans MS\";")
        self.query.setObjectName("query")
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(19, 220, 491, 41))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.exec = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.exec.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                "font: 10pt \"Comic Sans MS\";")
        self.exec.setObjectName("exec")
        self.horizontalLayout.addWidget(self.exec)
        spacerItem = QtWidgets.QSpacerItem(40, 20,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.reset = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.reset.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                 "font: 10pt \"Comic Sans MS\";")
        self.reset.setObjectName("reset")
        self.horizontalLayout.addWidget(self.reset)
        querybrowser.setCentralWidget(self.centralwidget)

        self.retranslateUi(querybrowser)
        QtCore.QMetaObject.connectSlotsByName(querybrowser)

        self.dbname = dn
        self.querybrowser = querybrowser
        querybrowser.setFixedSize(536, 282)
        self.reset.clicked.connect(self.resetevent)
        self.exec.clicked.connect(self.execevent)
        QMessageBox.about(
            self, "Message",
            "Only provide actions supported by the GUI to avoid errors.")

    def resetevent(self):
        self.query.setText("")
        self.query.setFocus()

    def execevent(self):
        sw = ''
        fw = ''
        query = str(self.query.toPlainText())
        query = query.strip()
        query1 = query.lower()
        f = 0
        q = ''
        count = 0
        cn = sqlite3.connect(self.dbname + '.db')
        crob = cn.cursor()
        try:
            crob.execute(query)
        except:
            f = 1
            QMessageBox.about(self, "Alert", "Some Error Occured.")
        cn.commit()
        cn.close()
        if f == 0:
            QMessageBox.about(self, "Message",
                              "Database Action Successfully Executed.")
            self.query.setText("")
            self.query.setFocus()
            for ch in query1:
                if ch != ' ':
                    q = q + ch
                else:
                    count += 1
                    if count == 1:
                        fw = q
                        q = q + ' '
                    if count == 2:
                        sw = q
                        break

            if sw == 'create table':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('table') + 6
                end = query1.index('(')
                tn = query[start:end]
                crob.execute(
                    "INSERT INTO TName(tname,dbname,query)VALUES(?,?,?);",
                    (tn, self.dbname, query))
                cn.commit()
                cn.close()

            elif sw == 'drop table':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('table') + 6
                tn = query[start:]
                crob.execute("DELETE FROM TName WHERE tname=? AND dbname=?;",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'create view':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('view') + 5
                end = query1.index('as') - 1
                tn = query[start:end]
                crob.execute("INSERT INTO VName(vname,dbname)VALUES(?,?);",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'drop view':
                cn = sqlite3.connect('sqlgenerator.db')
                crob = cn.cursor()
                start = query1.index('view') + 5
                tn = query[start:]
                crob.execute("DELETE FROM VName WHERE vname=? AND dbname=?;",
                             (tn, self.dbname))
                cn.commit()
                cn.close()

            elif sw == 'alter table':
                if query1.find('rename') > -1:
                    start = query1.index('table') + 6
                    end = query1.index('rename') - 1
                    tn = query[start:end]
                    start = query1.index('to') + 3
                    ntn = query[start:]
                    cn = sqlite3.connect('sqlgenerator.db')
                    crob = cn.cursor()
                    crob.execute("SELECT * FROM TName")
                    record = crob.fetchall()
                    for entry in record:
                        tname = str(entry[0])
                        dbn = str(entry[1])
                        if tname == tn and dbn == self.dbname:
                            q = str(entry[2])
                    crob.execute(
                        "UPDATE TName SET tname=? WHERE dbname=? AND query=?;",
                        (ntn, self.dbname, q))
                    cn.commit()
                    cn.close()
                    start = q.index('(')
                    qu = q[start:]
                    q = "CREATE TABLE " + ntn + qu
                    cn = sqlite3.connect('sqlgenerator.db')
                    crob = cn.cursor()
                    crob.execute(
                        "UPDATE TName SET query=? WHERE tname=? AND dbname=?;",
                        (q, ntn, self.dbname))
                    cn.commit()
                    cn.close()

                if query1.find('add') > -1:
                    start = query1.index('table') + 6
                    end = query1.index('add') - 1
                    tn = query[start:end]
                    cn = sqlite3.connect(self.dbname + '.db')
                    crob = cn.cursor()
                    sql = "SELECT sql FROM sqlite_master WHERE name='" + tn + "';"
                    crob.execute(sql)
                    result = crob.fetchone()
                    for record in result:
                        print(record)
                        cn1 = sqlite3.connect('sqlgenerator.db')
                        crob1 = cn1.cursor()
                        crob1.execute(
                            "UPDATE TName SET query=? WHERE tname=? AND dbname=?",
                            (record, tn, self.dbname))
                        cn1.commit()
                        cn1.close()
                    cn.commit()
                    cn.close()

            elif fw == 'select':
                cn = sqlite3.connect(self.dbname + '.db')
                crob = cn.cursor()
                crob.execute(query)
                result = crob.fetchall()
                cn.commit()
                cn.close()

                self.window = QtWidgets.QMainWindow()
                self.ui = Ui_display()
                self.ui.setupUi(self.window, result)
                self.window.show()
                self.querybrowser.close()

            elif fw == 'insert' or fw == 'delete' or fw == 'update':
                f = 0

            else:
                QMessageBox.about(
                    self, "Alert",
                    "Action NOT supported by the Application. \nThis modification may not be seen in the application."
                )

    def retranslateUi(self, querybrowser):
        _translate = QtCore.QCoreApplication.translate
        querybrowser.setWindowTitle(
            _translate("querybrowser", "Query Execution"))
        self.label.setText(_translate("querybrowser", " SQL Query:"))
        self.exec.setText(_translate("querybrowser", "Execute"))
        self.reset.setText(_translate("querybrowser", "Reset"))
Ejemplo n.º 6
0
class Ui_whereclause(QWidget):
    dbname = ""
    whereclause = None

    def setupUi(self, whereclause, dbname):
        whereclause.setObjectName("whereclause")
        whereclause.resize(403, 283)
        whereclause.setStyleSheet("background-color: rgb(255, 255, 191);")
        self.centralwidget = QtWidgets.QWidget(whereclause)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 0, 381, 211))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.fromlabel = QtWidgets.QLabel(self.gridLayoutWidget)
        self.fromlabel.setStyleSheet("font: 75 10pt \"Comic Sans MS\";")
        self.fromlabel.setObjectName("fromlabel")
        self.gridLayout.addWidget(self.fromlabel, 1, 0, 1, 1)
        self.whereentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.whereentry.setStyleSheet("font: 75 10pt \"Comic Sans MS\";\n"
                                      "background-color: rgb(255, 255, 255);")
        self.whereentry.setObjectName("whereentry")
        self.gridLayout.addWidget(self.whereentry, 2, 2, 1, 1)
        self.selectlabel = QtWidgets.QLabel(self.gridLayoutWidget)
        self.selectlabel.setStyleSheet("font: 75 10pt \"Comic Sans MS\";")
        self.selectlabel.setObjectName("selectlabel")
        self.gridLayout.addWidget(self.selectlabel, 0, 0, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(40, 20,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, 0, 1, 1, 1)
        self.wherelabel = QtWidgets.QLabel(self.gridLayoutWidget)
        self.wherelabel.setStyleSheet("font: 75 10pt \"Comic Sans MS\";")
        self.wherelabel.setObjectName("wherelabel")
        self.gridLayout.addWidget(self.wherelabel, 2, 0, 1, 1)
        self.fromentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.fromentry.setStyleSheet("font: 75 10pt \"Comic Sans MS\";\n"
                                     "background-color: rgb(255, 255, 255);")
        self.fromentry.setObjectName("fromentry")
        self.gridLayout.addWidget(self.fromentry, 1, 2, 1, 1)
        self.selectentry = QtWidgets.QLineEdit(self.gridLayoutWidget)
        self.selectentry.setStyleSheet("font: 75 10pt \"Comic Sans MS\";\n"
                                       "background-color: rgb(255, 255, 255);")
        self.selectentry.setObjectName("selectentry")
        self.gridLayout.addWidget(self.selectentry, 0, 2, 1, 1)
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 230, 381, 41))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.execute = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.execute.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                   "font: 75 12pt \"Comic Sans MS\";")
        self.execute.setObjectName("execute")
        self.horizontalLayout.addWidget(self.execute)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.reset = QtWidgets.QPushButton(self.horizontalLayoutWidget)
        self.reset.setStyleSheet("background-color: rgb(255, 255, 255);\n"
                                 "font: 75 12pt \"Comic Sans MS\";")
        self.reset.setObjectName("reset")
        self.horizontalLayout.addWidget(self.reset)
        self.line = QtWidgets.QFrame(self.centralwidget)
        self.line.setGeometry(QtCore.QRect(17, 200, 371, 20))
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        whereclause.setCentralWidget(self.centralwidget)

        self.retranslateUi(whereclause)
        QtCore.QMetaObject.connectSlotsByName(whereclause)
        whereclause.setFixedSize(403, 283)

        self.whereclause = whereclause
        self.dbname = dbname
        self.selectentry.setFocus()

        self.reset.clicked.connect(self.resetevent)
        self.execute.clicked.connect(self.executeevent)

    def resetevent(self):
        self.selectentry.setText("")
        self.fromentry.setText("")
        self.whereentry.setText("")
        self.selectentry.setFocus()

    def executeevent(self):
        se = self.selectentry.text()
        fe = self.fromentry.text()
        we = self.whereentry.text()
        if we == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif se == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        elif fe == "":
            QMessageBox.about(self, "Alert", "Fill all required entries.")
        else:
            query = "SELECT " + se + " FROM " + fe + " WHERE " + we + ";"
            cn = sqlite3.connect(self.dbname + '.db')
            crob = cn.cursor()
            crob.execute(query)
            result = crob.fetchall()
            cn.commit()
            cn.close()

            self.window = QtWidgets.QMainWindow()
            self.ui = Ui_display()
            self.ui.setupUi(self.window, result)
            self.window.show()
            self.whereclause.close()

    def retranslateUi(self, whereclause):
        _translate = QtCore.QCoreApplication.translate
        whereclause.setWindowTitle(_translate("whereclause", "WHERE"))
        self.fromlabel.setText(_translate("whereclause", "FROM"))
        self.selectlabel.setText(_translate("whereclause", "SELECT"))
        self.wherelabel.setText(_translate("whereclause", "WHERE"))
        self.execute.setText(_translate("whereclause", "Execute"))
        self.reset.setText(_translate("whereclause", "Reset"))