This code snippet is part of a telegram bot I am currently developing. I used the PyTelegramBotAPI package and used the @bot.callback_query_handler() to handle callback queries from users. I then created a function that prints out the last entry from a database for that particular user using the following code:
def splitbill(user):
row = c.execute('SELECT * FROM database WHERE user = (?) ORDER BY datetime DESC LIMIT 1', user).fetchall()
print(row[0])
This returned and error stating ValueError: parameters are of unsupported type
def splitbill(user):
row = c.execute('SELECT * FROM database WHERE user = (?) ORDER BY datetime DESC LIMIT 1', (user,)).fetchall()
print(row[0])
I googled and came upon this solution by using (user,) instead of (user). But I have no idea why it worked. Can someone enlighten me? Thank you!