Posts: 8,091
Threads: 154
Joined: Sep 2016
Jun-11-2020, 05:59 AM
(This post was last modified: Jun-11-2020, 05:59 AM by buran.)
(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.
Posts: 198
Threads: 17
Joined: Jun 2020
Posts: 2,164
Threads: 35
Joined: Sep 2016
your error states keys but the code shown does not contain keys ?
Posts: 1,822
Threads: 2
Joined: Apr 2017
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.
Posts: 8,091
Threads: 154
Joined: Sep 2016
Jun-11-2020, 06:04 AM
(This post was last modified: Jun-11-2020, 06:04 AM by buran.)
(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
Posts: 198
Threads: 17
Joined: Jun 2020
(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()
Posts: 2,164
Threads: 35
Joined: Sep 2016
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
Posts: 198
Threads: 17
Joined: Jun 2020
(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.
Posts: 8,091
Threads: 154
Joined: Sep 2016
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
Posts: 1,822
Threads: 2
Joined: Apr 2017
Jun-11-2020, 06:17 AM
(This post was last modified: Jun-11-2020, 06:17 AM by ndc85430.)
(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.
|