Python Forum

Full Version: Making a login page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
(Jun-11-2020, 05:57 AM)card51shor Wrote: [ -> ]what different code am i using?
the db.execute(...) line is different

You must pay more attention. And learn how to debug such simple errors on your own.
what does that mean?
your error states keys but the code shown does not contain keys ?
The traceback suggests that line 38 is the problem. You need to get used to reading those and working through your code to see what's wrong. Clearly you're passing a tuple on that line, so should you be passing a dict there?

FWIW, from the traceback, it looks like you're running locally on a Windows machine. By "online environment", I meant somewhere online that was running your application.
(Jun-11-2020, 05:59 AM)buran Wrote: [ -> ]the db.execute(...) line is different
Sorry, my error - I was looking at the INSERT statement in your code and comparing it with SELECT statement in the traceback

Yet another reason why you should post traceback here, not an image - I overlooked it while switch between tabs
(Jun-11-2020, 06:01 AM)ndc85430 Wrote: [ -> ]The traceback suggests that line 38 is the problem. You need to get used to reading those and working through your code to see what's wrong. Clearly you're passing a tuple on that line, so should you be passing a dict there?

FWIW, from the traceback, it looks like you're running locally on a Windows machine. By "online environment", I meant somewhere online that was running your application.

How do u know that is the problem and what is wrong with it? I say Fetchone() and not Fetchall()
this would give the error you are getting
a_tuple = (1, 2, 3)
a_tuple.keys
Error:
(base) C:\Users\Dave\Documents\VS Code WorkSpaces>C:/Users/Dave/anaconda3/python.exe "c:/Users/Dave/Documents/VS Code WorkSpaces/Python Forum/general/forumpost2.py" Traceback (most recent call last): File "c:/Users/Dave/Documents/VS Code WorkSpaces/Python Forum/general/forumpost2.py", line 2, in <module> a_tuple.keys AttributeError: 'tuple' object has no attribute 'keys'
because a_tuple indeed has no attribute keys
(Jun-11-2020, 06:04 AM)Yoriz Wrote: [ -> ]this would give the error you are getting
a_tuple = (1, 2, 3)
a_tuple.keys
Error:
(base) C:\Users\Dave\Documents\VS Code WorkSpaces>C:/Users/Dave/anaconda3/python.exe "c:/Users/Dave/Documents/VS Code WorkSpaces/Python Forum/general/forumpost2.py" Traceback (most recent call last): File "c:/Users/Dave/Documents/VS Code WorkSpaces/Python Forum/general/forumpost2.py", line 2, in <module> a_tuple.keys AttributeError: 'tuple' object has no attribute 'keys'
because a_tuple indeed has no attribute keys

I didn't have that line in my code, though.
fix this line
db.execute('SELECT * FROM users WHERE username = %s AND password = %s', (username, password,))
SQLalchemy doesn't like using tuple to pass values. It's again about how you pass values for placeholders in the sql statement you want to execute
(Jun-11-2020, 06:04 AM)card51shor Wrote: [ -> ]How do u know that is the problem and what is wrong with it? I say Fetchone() and not Fetchall()

By reading through the information presented: the traceback says that line 38 is the line in your code where the problem is and the error is about a tuple not having a property called keys. You're passing a tuple on line 38. It's pretty self-explanatory.
Pages: 1 2 3 4 5