Python and Sqlite3 inserting elements error -
i trying write data archive application. have gui (pyqt designer) show questions form user. there 13 questions , answers yes or no. , there 13 explanation them. create table in database, has 29 column. first column date , primary key. first tried text format date , explanations. gave varchar(5) yes , no's. didn't work same error this:
i applied solution code this:
isaretci.execute('insert oncekontrol (tarih, cvp1, aciklama1, cvp2, \ aciklama2, cvp3, aciklama3, cvp4, \ aciklama4, cvp5, aciklama5, cvp6, \ aciklama6, cvp7, aciklama7, cvp8, \ aciklama8, cvp9, aciklama9, cvp10, \ aciklama10, cvp11, aciklama11, cvp12, \ aciklama12, cvp13, aciklama13) values \ ({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},\ {11},{12},{13},{14},{15},{16},{17},{18},{19},\ {20},{21},{22},{23},{24},{25},{26}'\ .format (self.once[0], self.once[1], self.once[2], \ self.once[3], self.once[4], self.once[5], \ self.once[6], self.once[7], self.once[8], \ self.once[9], self.once[10], self.once[11], \ self.once[12], self.once[13], self.once[14], \ self.once[15], self.once[16], self.once[17], \ self.once[18], self.once[19], self.once[20], \ self.once[21], self.once[22], self.once[23], \ self.once[24], self.once[25], self.once[26]) )
tarih mean date, cvp[i]
mean answer, aciklama[i]
mean explanation. giving me error:
self.once[24], self.once[25], self.once[26],) ) sqlite3.operationalerror: near ",": syntax error
thanks in advance.
you're missing closing parenthesie
the insert statement needs insert table (header,...) values (val,...)
( {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},\ {11},{12},{13},{14},{15},{16},{17},{18},{19},\ {20},{21},{22},{23},{24},{25},{26} )' #added here
you should using safe approach
.execute("insert ... values (%s)" % ("?"*len(self.once)),self.ounce)
Comments
Post a Comment