Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Python read data MySQL column and use data in a if statement

This is my first question ever so sorry if its a bit inefficient.

Im creating an ATM with Python and MySQL for a school project. it needs to have balance, deposit and withdraw options. balance and deposit are done (pretty easy) but for withdraw i need a function that says "you are overdrawn" if the balance column drops below 0

What i need help with is reading input from the 'balance' column and using it in a if statement

psuedocode idea:

cur.execute(*) #the SQL statement to reduce the balance column by x
set data to ('balance data') #read the SQL data and set as variable
if data is less than 0
    send "you are overdrawn" to display
else
    db.commit() #the python command to edit the table
endif

i hope that helps to convey what i want to happen any help would be appreciated. i would ask my professor but im pretty sure i would loose marks if i did. any suggestions on how to format questions properly would also be apreciated. once again thanks

Comments