lundi 22 décembre 2014

How to update multiple rows in sqlite python with multiple WHERE parameters with python

I am creating an signing in/out app and I am using python 2.7 with a Sqlite database (DB). I was wondering if any one could help me, I am trying to write to a column in every row of the DB if the time in has a value, the time out doesn't have a value and the Reply (ticketing response by person) is Y. I'm a bit stuck at the moment and would really appreciate help :)! Note I am on a Macbook Pro 2013 late... Here is the the function I wrote which doesn't work, the statement updates all the timeout columns where the Reply = Y (I won't post the entire code as it over 300 lines long!)



conn = sqlite3.connect('resources/datalist.sqlite')
c = conn.cursor()
def allsure():

'sign out all students and message'
c.execute("UPDATE Table1 SET Time_out = TIME('now') WHERE Time_in IS NOT NULL AND Time_out ='' AND Reply = 'Y'")
conn.commit()

Aucun commentaire:

Enregistrer un commentaire