def getUserInfo(sender_id, requested_info): request_dict = {'id': ss.scr_dict['get_user_id']} con, curs = dbc.cnnct() curs.execute(request_dict[requested_info], {"sender_id": sender_id}) requested_info = curs.fetchone()[0] dbc.dscnnct(con, curs) return requested_info
def lastTenTransactions(sender_id): user_id = getUserInfo(sender_id, 'id') con, curs = dbc.cnnct() curs.execute(ss.scr_dict['get_last_ten_transactions'], {"user_id": user_id}) spending_data = curs.fetchmany(10) dbc.dscnnct(con, curs) return spending_data
def retrievePassword(email): con, curs = dbc.cnnct() curs.execute(ss.scr_dict['retrieve_password'], {"email": email}) try: hashed_password = curs.fetchone()[0] except TypeError: hashed_password = None dbc.dscnnct(con, curs) return hashed_password
def commitTransaction(sender_id, completed_transaction): con, curs = dbc.cnnct() curs.execute( ss.scr_dict['commit_transaction_2'], { "sender_id": sender_id, "item": completed_transaction['item'], "price": completed_transaction['price'], "vendor": completed_transaction['vendor'], "category": completed_transaction['category'] }) dbc.dscnnct(con, curs)
def add_new_transaction_ws(id, item, price, vendor, category): con, curs = dbc.cnnct() curs.execute( ss.scr_dict['add_new_transaction_ws'], { "id": id, "item": item, "price": price, "vendor": vendor, "category": category }) dbc.dscnnct(con, curs)
def createAccount(sender_id, state, user_info): creation_dict = { 'login': ss.scr_dict['create_account_login'], 'signup': ss.scr_dict['create_account_signup'] } con, curs = dbc.cnnct() curs.execute( creation_dict[state], { "sender_id": sender_id, "email": user_info['email'], "hashed_password": user_info['hashed_password'] }) dbc.dscnnct(con, curs)
def checkIfEmailInUse(email): con, curs = dbc.cnnct() curs.execute(ss.scr_dict['check_if_email_in_use'], {"email": email}) email_exists = curs.fetchone()[0] dbc.dscnnct(con, curs) return email_exists
def deleteUser(sender_id): con, curs = dbc.cnnct() curs.execute(ss.scr_dict['delete_user'], {"sender_id": sender_id}) dbc.dscnnct(con, curs)
def checkCreds(sender_id): con, curs = dbc.cnnct() curs.execute(ss.scr_dict['check_creds'], {"sender_id": sender_id}) creds_exist = curs.fetchone()[0] dbc.dscnnct(con, curs) return creds_exist
def get_last_ten_transactions_ws(id): con, curs = dbc.cnnct() curs.execute(ss.scr_dict['get_last_ten_transactions_ws'], {"id": id}) spending_data = curs.fetchmany(10) dbc.dscnnct(con, curs) return spending_data