Example #1
0
    def onClickedOK(self):
        rows = cont.tableWidget.currentRow()
        item = cont.tableWidget.item(rows, 0)
        self.error = Error()
        self.error2 = Error2()

        try:
            ID = item.text()

        except:
            self.error.show()
            control.SetEnabled_False(cont)

        else:
            control.SetEnabled_True(cont)

            # connect to the database
            constr = "dbname=testdb host={} port={} user=postgres".format(
                host, port)
            conn = psycopg2.connect(constr)

            # create a cursor
            cur = conn.cursor()
            userName = getpass.getuser()
            #cur = conn.cursor(name=userName)

            # extract all the data
            tablename = "address"

            # delete the data

            try:
                sql = 'delete from {} where "ID" = {}'.format(tablename, ID)

            except UnboundLocalError:
                self.error.show()
                control.SetEnabled_False(cont)

            else:
                try:
                    cur.execute(sql)
                except psycopg2.ProgrammingError:
                    self.error2.show()
                    control.SetEnabled_False(cont)

            # close the cursor and connection
            finally:
                conn.commit()
                #cur.close()
                conn.close()
                cont.tableWidget.clearContents()
                control.updateUi(cont, host, port)
Example #2
0
 def onClickedCancel(self):
     control.SetEnabled_True(cont)
     cont.tableWidget.clearContents()
     control.updateUi(cont, host, port)
Example #3
0
 def onClickedOK(self):
     control.SetEnabled_True(cont)
     control.Henshuu(cont2, cont2_2, ID, host, port)
     cont.tableWidget.clearContents()
     control.updateUi(cont, host, port)
Example #4
0
 def onClickedOK(self):
     control.Shinki(cont1)
     cont.tableWidget.clearContents()
     control.updateUi(cont, host, port)
     control.SetEnabled_True(cont)
     control.dataClear(cont1)