lundi 30 novembre 2015

How to change the value of a cell in a databse using SQLITE and Python

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

Aucun commentaire:

Enregistrer un commentaire