Hi
I am writing a function which gets values. These ones will be used in my sqlite query
def updateDB(tel, month, price):
mytel = (tel,)
myprice = (price,)
connection = sqlite.connect("mydb.db")
cursor = connection.cursor()
sql = 'UPDATE mydatabase SET %s = ? WHERE number = ?'
cursor.execute( sql % (month), (myprice, mytel))
connection.commit()
...and so on....
I think probably I tried all the possibilities to make it work except the right one...I miss the right syntax.
It works well if I give the name of the column instead of %s so it will:
sql = 'UPDATE mydatabase SET "jan" = ? WHERE number = ?'
cursor.execute( sql , (myprice, mytel))
It works well if i keep the column and remove the "WHERE number = ?":
sql = 'UPDATE mydatabase SET %s = ? '
cursor.execute( sql %(month), (myprice))
Can someone help me with it?
It will be useful instead of writing a fuction for every month...