0
 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)
0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.