0
x = self.npprocess_PTE.text()
    y = 123
    if len(self.npprocess_PTE.text()) == 0:
       print("yes") 
    else:
       model = QtGui.QStandardItemModel()
       self.npprocessview_LV.setModel(model)
       z = model.rowCount()
       z = z + 1
       a = str(z)+'_Process'
       b = "INSERT INTO new_part_info(%s) VALUES(%s) WHERE Part_ID = %s"
       c = (z, x, y)
       mycursor.execute(b, c)
       mydb.commit()

The error i am getting:u have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1) VALUES('wb') WHERE Part_ID = 123' at line 1

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

1

There are two errors that I can see in your insert query:

  1. As others pointed out, insert statement does not have a where clause. Either you need to get rid of it, or you need to change the insert into an update. However, this is not the error that causes the error message.

  2. You use z variable as the name of the column for the insert. z is a number. As mysql manual on object identifiers says:

Identifiers may begin with a digit but unless quoted may not consist solely of digits.

So, you need to quote the value in z:

w = '`' + str(z) + '`'

and then use w insted of z when executing the insert. Alternatively, you need to use a variable instead of z, since it is created as:

a = str(z)+'_Process'

It depends on the name of the columns within your table, really.

Shadow
  • 33,525
  • 10
  • 51
  • 64