def fetchStepByEmailStep(email, step): cursor = mysql.connection.cursor() cursor.execute( "select email,step, deadline, expectedOutput, tasks from step where email='%s' and step='%s'" % (email, step)) stepRaw = cursor.fetchone() if stepRaw is None: return None step = Step() step.email = stepRaw[0] step.step = stepRaw[1] step.deadline = stepRaw[2] step.expectedOutput = stepRaw[3] step.tasks = stepRaw[4].split(",") mysql.connection.commit() cursor.close() return step
def fetchStepNotExceed(email): cursor = mysql.connection.cursor() cursor.execute( "select email,step, deadline, expectedOutput, tasks from step where deadline >= now() and email='%s'" % (email)) sr = cursor.fetchall() stepList = [] for sr in sr: if sr is not None: step = Step() step.email = sr[0] step.step = sr[1] step.deadline = sr[2] step.expectedOutput = sr[3] step.tasks = sr[4].split(",") stepList.append(step) mysql.connection.commit() cursor.close() return stepList