system.db.runUpdateQuery

I want to be able to add a row to a table / SQL database. I have made what I am trying to do more basic to try and get that working before I go any further. I have a textbox where I enter the description, and I am taking the last part ID in the SQL database and adding 1 to it for the next part ID. What I have works for the table / dataset portion of it, but I am having problems updating the SQL database. The following is my code on the button “actionPerformed” event

table = event.source.parent.getComponent('Table')
partname = event.source.parent.getComponent('partName').text
nextpartid = system.db.runScalarQuery("SELECT MAX(`part_id`) + 1 FROM parts")

table.data = system.dataset.addRow(table.data, [nextpartid, partname, partdesc, user,station, assigndate ,None ,])
system.db.runUpdateQuery("INSERT INTO parts (part_id, part_name,) VALUES (%d, %f)" % (nextpartid, partname))

The error I am getting is “Error executing script for event: actionPerformed on component: add.”

I am basically copying the exact same code snippet from the manual. if I run the SQL query on the database query browser it works (with fixed values instead of variable).

Any advice to get this working? Should I be going in a different direction? It seems a bit awkward updating the table and the SQL database separately.

In your scalar query, have you tried removing the single quotes? I tried running the same select query and ended up having an issue with the SQL MAX() function thinking the column name was a varchar value and failed.

That portion of the code always worked, and when I remove the quotes it still worked.

My error is being generated from the system.db.runUpdateQuery line of code for some reason.