Can you set a variable for LIMIT OFFSET in SQLite?

Viewed 99

So I was doing a project that required us to create a program in python and I was wondering if you could use a variable for the OFFSET value so that it can be increased through "if" functions.

Here is the code I came up with.

> c.execute("SELECT * FROM Book_reservation WHERE Status='Pending' LIMIT 20 OFFSET ?",(Num))

But when I tried it, all I got was a "parameters are of unsupported type" error message. Is there any way to make it work?

1 Answers

An int in parentheses is just an int. See what type( (5) ) returns. The argument to execute requires a sequence. It will be seen as a tuple if written (Num,). Or the argument can be a list, eg [Num].

Related