Query Syntax Error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Query Syntax Error (/thread-35951.html) |
Query Syntax Error - hammer - Jan-02-2022 I have compared this code with similar queries that work. Can anyone see what I am missing that is causing the Syntax Error?
def insert_Cow(self,tagNo,tagClr,tagYr,type,des, loc,locDte,birthDte,birthWt,weanDte,weanWt,sex,status,aquired, aquiredDte,aquiredCst,disposition,dispDte,soldAmt,bredDte, bullTagNo,bullTagClr,bullTagYr,actCalvDte,calfTagNo,calfTagClr,calfTagYr): self.c.execute(""" INSERT INTO cowTbl VALUES tagNo=?, tagClr=?, tagYr=?, type=?, desc=?, loc=?, locDte=?, birthDte=?, birthWt=?, weanDte=?, weanWt=?, sex=?, status=?, aquired=?, aquiredDte=?, aquiredCst=?, disposition=?, dispositionDte=?, soldAmt=?, bredDte=?, bredByTag=?, bredByTagClr=?, bredByTagYr=?, actCalvDte=?, calfTagNo=?, calfTagClr=?, calfTagYr=? """, (tagNo,tagClr,tagYr,type,des,loc,locDte,birthDte,birthWt,weanDte,weanWt,sex,status,aquired, aquiredDte,aquiredCst,disposition,dispDte,soldAmt,bredDte, bullTagNo,bullTagClr,bullTagYr,actCalvDte,calfTagNo,calfTagClr,calfTagYr)) self.con.commit() RE: Query Syntax Error - menator01 - Jan-02-2022 Probable should look a little closer at your query structure. I've tried unsuccessfully inserting data with that structure. Doing something like: def insert(*args): cur.execute('insert into cowTbl values (?,?,?,?)', args) # This structure works conn.commit() insert(34, 'data45', 'data29', 'data34')worked for me. RE: Query Syntax Error - hammer - Jan-03-2022 Problem resolved using your structure. thank you. |