Esempio n. 1
0
def update_account_info(account, field_name, value):
    update_query = f'update account_types set {field_name} = "{value}" where account_type_id = "{account.account_type_id}"'
    cursor = db.cursor()
    cursor.execute(update_query)
    db.commit()
    cursor.close()
    print('Account type has been updated')
Esempio n. 2
0
def delete_user(username):
    my_cursor = db.cursor()
    delete_query = f'delete from users where username = "******"'
    my_cursor.execute(delete_query)
    db.commit()
    my_cursor.close()
    print('User successfully deleted')
Esempio n. 3
0
def insert_bank(bank):
    my_cursor = db.cursor()
    insert_query = f'insert into banks (bank_name, location) VALUES ("{bank.name}", "{bank.location}")'
    my_cursor.execute(insert_query)
    db.commit()
    my_cursor.close()
    print("Bank successfully inserted into banks table\n")
Esempio n. 4
0
def update_bank(bank):
    update_query = f'update banks set bank_name = "{bank.name}", location = "{bank.location}" ' \
                   f'where bank_id = "{bank.bank_id}"'
    my_cursor = db.cursor()
    my_cursor.execute(update_query)
    db.commit()
    my_cursor.close()
    print("Bank has been updated")
Esempio n. 5
0
def add_account_db(account):
    insert_query = f'insert into accounts (bank, account_number, balance, account_holder, account_type,' \
                   f'date_created) values ("{account.bank}", "{account.account_number}", "{account.balance}", ' \
                   f'"{account.account_holder}", "{account.account_type_id}", "{account.date_created}");'
    cursor = db.cursor()
    cursor.execute(insert_query)
    db.commit()
    cursor.close()
    print('Account successfully inserted into accounts table')
Esempio n. 6
0
def insert_account_type(account_type):
    cursor = db.cursor()
    insert_query = f'insert into account_types (account_type, bank, interest_rate, monthly_fees, minimum_balance, ' \
                   f'max_withdrawals) values ("{account_type.account_type}", "{account_type.bank}", ' \
                   f'"{account_type.interest_rate}", "{account_type.monthly_fees}", "{account_type.minimum_balance}"' \
                   f', "{account_type.max_withdrawals}") '
    cursor.execute(insert_query)
    db.commit()
    cursor.close()
    print('Account type successfully inserted into account_types table')
Esempio n. 7
0
def insert_user(user):
    my_cursor = db.cursor()
    if user.bank is None:
        user.bank = "NULL"
    insert_query = ("insert into users (first_name, last_name, username, password, dob, ssn, email, bank) VALUES "
                    f"('{user.first_name}', '{user.last_name}', '{user.username}', '{user.password}', "
                    f"STR_TO_DATE('{user.dob}','%Y-%m-%d'), '{user.ssn}', '{user.email}', '{user.bank}') ")
    my_cursor.execute(insert_query)
    db.commit()
    my_cursor.close()
    print("User successfully inserted into users table\n")
Esempio n. 8
0
def remove_account_type(type_id):
    cursor = db.cursor()
    delete_query = f'delete from account_types where account_type_id = "{type_id}"'
    cursor.execute(delete_query)
    db.commit()
    update_referencing_accounts_query = f'update accounts set account_type_id = NULL where account_type_id = ' \
                                        f'"{type_id}"'
    cursor.execute(update_referencing_accounts_query)
    db.commit()
    cursor.close()
    print('Account type successfully deleted')
Esempio n. 9
0
def remove_bank(bank):
    my_cursor = db.cursor()
    delete_query = f'delete from banks where bank_id = "{bank.bank_id}"'
    my_cursor.execute(delete_query)
    db.commit()
    update_bank_in_users_query = f'update users set bank = NULL where bank = "{bank.bank_id}"'
    my_cursor.execute(update_bank_in_users_query)
    db.commit()
    update_account_types_query = f'delete from account_types where bank = "{bank.bank_id}"'
    my_cursor.execute(update_account_types_query)
    db.commit()
    my_cursor.close()
    print('Bank successfully deleted')
    return None