Reputation: 3
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) |
Upvotes: 0
Views: 29
Reputation: 54698
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.
Upvotes: 1