Forums

What does this error mean?

2021-04-21 16:38:51,563: Exception on /register [POST]

033[33mTraceback (most recent call last):#033[0m**

File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/moneynotes/mysite/application.py", line 103, in register rows = db.execute("SELECT * FROM users WHERE username = :username", username=username)

033[33mAttributeError: 'str' object has no attribute 'execute'#033[0m

and

2021-04-21 16:47:49,431: Exception on /login [POST]

033[33mTraceback (most recent call last):#033[0m

File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise raise value File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/home/moneynotes/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functionsrule.endpoint File "/home/moneynotes/mysite/application.py", line 79, in login rows = db.execute("SELECT * FROM users WHERE username = username", username=request.form.get("username"))

033[33mAttributeError: 'str' object has no attribute 'execute'#033[0m

"AttributeError: 'str' object has no attribute 'execute'" means that the variable that you're trying to call the execute method on (db) is a str object and str objects do not have an execute method.

It looks like you're expecting db to be some sort of database connection, but instead it's a string. Check you code where you assign to db and make sure it's a database connection object and not a string.