Delete data in a POSTGRES row

Hi all, I have the following problem.
Practically in a power table connected to a POSTGRES table I can insert and modify data of any type.
My problem is as follows.
How can I go about deleting data in a table row via a button script?

This is the script in Power Table :
def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue):

Index = self.data.getValueAt(rowIndex,colIndex)
    
column = '"'+ colName+ '"' 

# Create a Python dictionary of parameters to pass.
parameters  = {"nq_id": self.data.getValueAt(rowIndex,0) , "nq_col":column, "nq_val": newValue}

if colName == "PesoSpecifico":
	# Run the Named Query.
	system.db.runNamedQuery("PesoSpecifico", parameters)	
else:
	# Run the Named Query.
	system.db.runNamedQuery("Prodotti", parameters)
    
# Refresh Table
self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)

I want to clarify that I can perfectly modify the table with this script (NAMED QUERIES)
I would basically like to select a row and clear the values ​​of that row with a script in a button.
Now I can do it but I have to go to each value and delete them one by one, very inconvenient for my client.

If I'm understanding you correctly, it sounds like you want to select multiple rows in your power table, and then construct a DELETE FROM script that fires from a button.

Getting the selected row data from a power table is relatively simple.
Example:

table = event.source.parent.getComponent('Power Table').table
for row in table.selectedRows:
	for column in range(table.columnCount):
		value = table.getValueAt(row, column)
		#do whatever you want with value

This script gets the selected rows from the table and then iterates through the columns in those rows to return all of the data. In your usage case, you will want to modify this in a way that targets the primary key, so you can be sure your query deletes the correct row.

Example:

table = event.source.parent.getComponent('Power Table').table
for row in table.selectedRows:
	for column in range(table.columnCount):
		columnName = table.getColumnName(column)
		if columnName == "PesoSpecifico":
			primaryKey = table.getValueAt(row, column)
			#DELETE FROM db.table WHERE...