if message.content.startswith("!Cooltime"):
con = sqlite3.connect("Hamal.db")
cur = con.cursor()
cur.execute(f"SELECT CoolTime FROM UserInfo WHERE DiscordId = {message.author.id}")
exist = cur.fetchone()
#------here--------
if exist == 100:
print(1)
if exist == 200:
print(2)
#-----------------
I select "Cooltime"columns where the "DiscordID" is the message author's DiscordId but, it doesn't working at "here"
And here is the sqlite3 Db
| CoolTime | DiscordID |
|---|---|
| 100 | (user's id 1) |
| 200 | (user's id 2) |
1 Answer 1
fetchone() ALWAYS returns a tuple, even when there's only one column. Use exist[0] to extract the first/only column.
And, by the way, the simple debugging step of printing the intermediate result would have told you this at once.
answered Oct 6, 2021 at 6:29
Tim Roberts
55.3k4 gold badges29 silver badges41 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default