[SOLVED] Deleting rows from a SQL table using RunPrepQuery

I have some code here that lets the user drag and drop data from one power table to the next:

if system.gui.confirm("Are you sure you want to scrap this part?", "Recycle?"):
	if self != sourceTable:
		destDataset = self.getData()
		pyRowData = system.dataset.toPyDataSet(rowData)
		for row in pyRowData:
			newRow = []
			for column in row:
			destDataset = system.dataset.addRow(destDataset, dropIndexLocation, newRow)

		system.db.runPrepQuery("DELETE FROM my_Table WHERE RFID = ?;", [destDataset.getValueAt(0,0)])
		sourceTable = results
		system.gui.messageBox("Dropping on to same table not supported")

However it seems that no matter what syntax I try the sql table is never actually updated. Does anyone know what my runPrepQuery is missing?

Try using system.db.runPrepUpdate()


That worked thank you. Is there a way to also delete the row I copied into the destination power table?

newDataset = system.dataset.deleteRows(self.getData(), rows)

The above isn’t cutting it…

Have you tried

self.data = newDataset

Yes, did not work.

self.data = system.dataset.deleteRow(self.data, 0)

This worked for me.

Glad you got it sorted out! :slight_smile: