Jun-11-2020, 05:59 AM
(Jun-11-2020, 05:57 AM)card51shor Wrote: [ -> ]what different code am i using?the
db.execute(...)
line is differentYou must pay more attention. And learn how to debug such simple errors on your own.
(Jun-11-2020, 05:57 AM)card51shor Wrote: [ -> ]what different code am i using?the
db.execute(...)
line is differentkeys
but the code shown does not contain keys
?(Jun-11-2020, 05:59 AM)buran Wrote: [ -> ]the db.execute(...) line is differentSorry, my error - I was looking at the INSERT statement in your code and comparing it with
SELECT
statement in the traceback(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.
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.keysbecause
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'a_tuple
indeed has no attributekeys
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()
keys
. You're passing a tuple on line 38. It's pretty self-explanatory.