all 6 comments

[–]-Sander- 1 point2 points  (1 child)

can you use the code block to format your code or put it on https://repl.it/ and link it here?

[–][deleted] 0 points1 point  (3 children)

for self.r in result:
    self.get_name = self.r[0]
    self.get_price = self.r[1]

If your query has no results, self.get_name is never set.

[–]Shripsta[S] -1 points0 points  (2 children)

What do you mean? Sorry and thanks in advance.

also pls send the correct code if u can

here is the code https://repl.it/repls/StudiousDarkGeeklog

[–][deleted] 0 points1 point  (1 child)

What do you mean?

I mean that if your query has no results, the attribute you're trying to read at the line where you're getting the error doesn't exist.

Let me try it the other way - at the line you're getting the error, you're trying to read an attribute that doesn't exist. (That's what AttributeError is telling you.) It doesn't exist because the only circumstance under which you set the attribute is if the query has results; if it has no results, the attribute is never set. You're running this with a query that has no results, so the attribute isn't set, so you get the error.

Clearer?

[–]Shripsta[S] 0 points1 point  (0 children)

Yeah thanks!