vendredi 29 avril 2016

Updating sqlite database, when the column and row is not known before

Hi so Im trying to update my table, in which the user can select the column and row he wants to update though variables. Here what i have done so far. I am getting the error
sqlite3.OperationalError: near "Tree": syntax error

 def MDConfirm_btn_clicked(self,MGStudent_drop):

   Max_marks=int(self.MDMax_inp.text()) #take input from maximim  marks entry  

   Marks_scored= int(self.MDAch_inp.text()) #take input from maximim  marks entry  

   Percentage_scored = (Max_marks/Marks_scored)*100  #formula to find percentage

   Current_student = (self.MGStudent_drop.currentText()) #take data held in student name drop down

   Current_topic= (self.MGMarks_drop.currentText()) #take data held in topic drop down


   con = lite.connect('Student_names')#Links code to the data base file
   cur = con.cursor() 
   myquery=("UPDATE gradesdb SET {cn}=(?) WHERE Names=(?)".\
    format( cn=Current_topic))

   cur.execute(myquery,(Percentage_scored,Current_student))     
   con.commit()

Aucun commentaire:

Enregistrer un commentaire