def get_one_by_token(db, token): c = db.cursor() q_str = db_helpers.select_where_string(TABLE_NAME, [FIELD_TOKEN, FIELD_EMAIL], FIELD_TOKEN) c.execute(q_str, [token]) resets = [Reset(r[0], r[1]) for r in c.fetchall()] if len(resets) < 1: return None return resets[0]
def get_one_by_email(db, email): if email is None: return None q_str = db_helpers.select_where_string(TABLE_NAME, [FIELD_EMAIL, FIELD_TOKEN], FIELD_EMAIL) c = db.cursor() c.execute(q_str, [email]) user_sessions = [Session(r[0], r[1]) for r in c.fetchall()] if len(user_sessions) < 1: return None return user_sessions[0]
def get_one_by_email(db, email): if email is None: return None q_str = db_helpers.select_where_string( TABLE_NAME, [FIELD_EMAIL, FIELD_PASSHASH, FIELD_GUESTACCOUNT], FIELD_EMAIL) c = db.cursor() c.execute(q_str, [email]) users = [User(r[0], r[1], r[2]) for r in c.fetchall()] if len(users) < 1: return None return users[0]
def select_all_not_in_progress(db): # we want requests not in progress in_progress = False # generate the full select with where for the constructor q_str = db_helpers.select_where_string(TABLE_NAME, CONSTRUCTOR_FIELDS, FIELD_INPROGRESS) # and select c = db.cursor() c.execute(q_str, [in_progress]) reqs = [ Request(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]) for r in c.fetchall() ] return reqs
def select_by_email(db, email): # no nulls if email is None: return None # generate the full select with where for the constructor q_str = db_helpers.select_where_string(TABLE_NAME, CONSTRUCTOR_FIELDS, FIELD_EMAIL) # and select c = db.cursor() c.execute(q_str, [email]) reqs = [ Request(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]) for r in c.fetchall() ] return reqs
def select_one_by_id(db, req_id): # no nulls if req_id is None: return None # generate the full select with where for the constructor q_str = db_helpers.select_where_string(TABLE_NAME, CONSTRUCTOR_FIELDS, FIELD_REQUESTID) # and select c = db.cursor() c.execute(q_str, [req_id]) reqs = [ Request(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]) for r in c.fetchall() ] # there should only be one if len(reqs) < 1: return None return reqs[0]