def submit_request(db, email, name, params_dict): print('hit submit_request') # no nulls if email is None or name is None or params_dict is None: print('None in submit_request {0}'.format([email, name, params_dict])) return # generate a full insert string q_str = db_helpers.insert_into_string(TABLE_NAME, ORDERED_FIELDS_NO_ID) # need to dump params to json for storage params = json.dumps(params_dict) # and results are empty for now results = json.dumps({}) # submit time is right now submit_time = datetime.datetime.utcnow().isoformat() # complete time hasn't happened complete_time = DATE_DMY.isoformat() # not in progress and not done in_progress = False done = False # let's do this vals = [ email, name, params, results, submit_time, complete_time, in_progress, done ] c = db.cursor() c.execute(q_str, vals) db.commit()
def create_event(db, email, event_type): event_timestamp = datetime.datetime.utcnow().isoformat() # put together the query q_str = db_helpers.insert_into_string( TABLE_NAME, [FIELD_EMAIL, FIELD_EVENTTYPE, FIELD_TIMESTAMP]) c = db.cursor() c.execute(q_str, [email, event_type, event_timestamp]) db.commit()
def create_user_account(db, email, pass_hash): create_time = datetime.datetime.utcnow().isoformat() last_login = create_time q_str = db_helpers.insert_into_string( TABLE_NAME, [FIELD_EMAIL, FIELD_PASSHASH, FIELD_CREATETIME, FIELD_LASTLOGIN]) c = db.cursor() c.execute(q_str, [email, pass_hash, create_time, last_login]) db.commit() return get_one_by_email(db, email)
def insert_token(db, token, email): c = db.cursor() q_str = db_helpers.insert_into_string(TABLE_NAME, [FIELD_TOKEN, FIELD_EMAIL]) c.execute(q_str, [token, email]) db.commit()
def create_session_token(db, email, token): c = db.cursor() q_str = db_helpers.insert_into_string(TABLE_NAME, [FIELD_EMAIL, FIELD_TOKEN]) c.execute(q_str, [email, token]) db.commit()