2 Replies - 602 Views - Last Post: 18 April 2013 - 12:42 PM Rate Topic: -----

#1 sara20  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-April 13

How to update a single row in a table, instead of adding new ones

Posted 10 April 2013 - 12:44 PM

I have written a GUI that gets data sent to it in real time and this data is displayed in a table. Every time data is sent in it is displayed in the table in a new row. My problem is that I would like to have the data just replace the old in the first row.

The table has 6 columns (A, B, C, D, E, F) I want the new data to continue replacing the old data in the same row unless the data that goes under column A changes, at which point a new row would be added.

I hope that wasn't confusing and I could really use any kind of help.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: How to update a single row in a table, instead of adding new ones

#2 atraub  Icon User is offline

  • Pythoneer
  • member icon

Reputation: 759
  • View blog
  • Posts: 2,010
  • Joined: 23-December 08

Re: How to update a single row in a table, instead of adding new ones

Posted 10 April 2013 - 06:17 PM

Without knowing the type of database, it'll be hard to actually help. However, if you know how to create a row, then updating a row should be rather straightforward.

So, what type of db are you using?
Was This Post Helpful? 0
  • +
  • -

#3 sara20  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-April 13

Re: How to update a single row in a table, instead of adding new ones

Posted 18 April 2013 - 12:42 PM

View Postatraub, on 10 April 2013 - 06:17 PM, said:

Without knowing the type of database, it'll be hard to actually help. However, if you know how to create a row, then updating a row should be rather straightforward.

So, what type of db are you using?



Well my code is written in python and to build the GUI i am using PyQt4. The code for the table is this:


 data = self.data                
        # Populates table by adding only new entries to the end of the table
        lastRow = self.table.rowCount()
        self.table.setRowCount(len(data))
        for entryPos in range(lastRow, len(data)):                              
            for fieldPos in range(5):                                         
                item = QtGui.QTableWidgetItem(data[entryPos][fieldPos])
                self.table.setItem(entryPos, fieldPos, item)
        self.table.resizeColumnsToContents()




….and I have this code above it…

entry = (time, 'EPC', str(msg.arg2()), epc_data, snr)    
self.data.append(entry) 
                                   


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1