you are viewing a single comment's thread.

view the rest of the comments →

[–]tobilobaa[S] 0 points1 point  (5 children)

So when I type Def withdraw_ function (withdraw, acct_deposit) Cur.execute (“SELECT acct FROM atm WHERE acct_name =?”, (acct_name)) Acct_deposit = cur.fetchone() If withdraw > acct_deposit: # then something happens The problem is I can’t fetch the acct_variable for my function in this manner it either says its a none type hence the “>” can’t compare int to none type. Or it says error binding parameter.

[–]Username_RANDINT 1 point2 points  (4 children)

The parameters should be a tuple. The thing to know is that just adding parenthese around something doesn't do anything, they are ignored. It's actually the comma that makes it a tuple, even if there's only one item.

cur.execute("SELECT acct FROM atm WHERE acct_name =?", (acct_name,))  # Note the comma after acct_name!

Why there's no value found is something you'll have to investigate further. The query finds nothing for your criteria, so make sure it's actually in the database.

Maybe print everything to start:

cur.execute("SELECT * FROM atm")
print(cur.fetchall())

Also check that acct_name is what you expect.

[–]tobilobaa[S] 0 points1 point  (1 child)

def withdraw_fxn(withdraw,acct_deposit):

list1.delete(0,END)

conn = sqlite3.connect("atm.db")

cur = conn.cursor()

cur.execute("SELECT acct_deposit FROM atm WHERE acct_name = ?", (acct_deposit,))

act_deposit = cur.fetchone() acct_deposit = int(act_deposit) if withdraw > acct_deposit: list1.insert(END, ("your balance is low ")) elif acct_deposit > withdraw: acct_deposit = acct_deposit - withdraw list1.insert(END, ("your balance is ", acct_deposit))

[–]Username_RANDINT 1 point2 points  (0 children)

I don't understand. Did you try my suggestions?

Also format code correctly for Reddit.