Python Forum

Full Version: SQL query with a variable amount of parameters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Nothing works! :(
I've tried them as a tuple, I even tried it as a hardcoded list or tuple. like items_IDs = [4,5,6,7]. I get the same error, function simply doesn't recognize it as a set of multiple items, it sees it as just one.

Update:
Managed to solve it, although I kinda can't understand the issue:

def sql_select(query, *args):
    . . .
    db.execute(query, *args)
I've added the asterisk inside the body and it works now. But in none of the examples I've seen, asterisk was used there, only in the head section of the function.
Pages: 1 2