in scripts/bank_deposit.py [0:0]
def make_deposit(conn):
# ask for deposit
while True:
try:
print("Make a deposit to your checking account.")
deposit_amount=input("Enter deposit amount ($): ")
deposit_amount = int(deposit_amount)
if isinstance(deposit_amount, int) is False:
raise ValueError("Please deposit full dollar amounts!")
except ValueError:
print("Please deposit full dollar amounts!")
continue
else:
break
# deposit the amount
conn.begin()
with conn.cursor() as cursor:
cursor.execute("INSERT INTO `transactions` (`account_number`, `trx_medium`, `trx_type`, `trx_amount`) VALUES ('012948503534', 'Cash', 'Deposit', %d);" % deposit_amount)
cursor.execute("UPDATE `accounts` SET `total_balance` = `total_balance` + %d WHERE `account_number` = '012948503534';" % deposit_amount)
cursor.close()
conn.commit()