2

Ok, so I'm putting a list of 25 tuples, with each tuple containing 5 items, into an sqlite database. Each time I try the main code to write, I get "apsw.SQLError: SQLError: near "?": syntax error" Here's the code I'm running. Be aware that this is part of a much, much larger server project for a game, so some of the functions will be unknown to you.

def writetable(self,blockoffset,matbefore,matafter,name,date):
 self.blocklist.append((blockoffset,matbefore,matafter,name,date))
 if len(self.blocklist) > 25:
 self.memcursor.executemany("INSERT OR REPLACE INTO main (?,?,?,?,?)",self.blocklist)
 blocklist.clear()
 print("Memory Database updated")
asked Oct 31, 2010 at 22:22

2 Answers 2

3

I believe it should be:

self.memcursor.executemany("INSERT OR REPLACE INTO main VALUES (?,?,?,?,?)",self.blocklist)
answered Oct 31, 2010 at 22:28
Sign up to request clarification or add additional context in comments.

2 Comments

facepalm Well, Im sorry for troubling stackoverflow with this question. Though, I wish the error message was more specific..
you can always try to run a failing command on the sqlite3 command line, you will get better errors there I think.
0

You probably forgot the VALUES keyword:

 self.memcursor.executemany("INSERT OR REPLACE INTO main VALUES (?,?,?,?,?)",self.blocklist)

Have a look here for the correct syntax.

answered Oct 31, 2010 at 22:32

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.