0
def update_account_balance(db, clientnum, account, changebalance):
return run_command(db, "UPDATE Accounts SET ? = ? + ? WHERE Number is ?", 
(account, account, changebalance, clientnum))

Where run_command is:

con =  sqlite3.connect(db)
cur =  con.cursor()
if args == None:
    cur.execute(command)
else:
    cur.execute(command, args)
result_L = cur.fetchall()    
cur.close()
con.commit()
con.close()
return result_L

So basically what I'm trying to do is set a bunch of '?' to values after my sql statement but when ever I run it says, "sqlite3.OperationalError: near "?": syntax error" How do I fix this? Thank you

Dahab
  • 3
  • 4
  • TL;DR you cant have table names or column names as parameterized substitutions – R Nar Dec 01 '15 at 00:04
  • 1
    [this question](http://stackoverflow.com/questions/13880786/python-sqlite3-string-variable-in-execute) is even better in explaining that – R Nar Dec 01 '15 at 00:09
  • @RNar Thanks for showing me that but now when I do it, it returns an empty list, Im trying to get the new balance as a float – Dahab Dec 01 '15 at 00:35
  • `UPDATE` queries dont have any return value so of course it returns an empty list? – R Nar Dec 01 '15 at 00:36

0 Answers0