Python Forum
SQL query with a variable amount of parameters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL query with a variable amount of parameters
#11
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Get amount of bytes in a file chesschaser 1 1,544 Aug-23-2021, 03:24 PM
Last Post: deanhystad
  Moving large amount of data between MySql and Sql Server using Python ste80adr 4 3,326 Apr-24-2020, 01:24 PM
Last Post: Jeff900
  Add Variable to select query UtiliseIT 2 2,602 May-03-2019, 11:45 AM
Last Post: UtiliseIT
  SELECT statement query question using a variable DT2000 2 2,983 Feb-23-2019, 07:35 AM
Last Post: DT2000
  Have an amount of time to perform and action CookieGamez2018 1 2,916 Dec-21-2018, 07:12 AM
Last Post: Gribouillis
  Why I get RecursionError on very small amount of data? wavic 3 3,890 Aug-05-2018, 04:55 PM
Last Post: micseydel
  python variable in SQL query takaa 5 31,344 Nov-23-2017, 10:12 AM
Last Post: takaa
  search and replace first amount of strings instances with one thing and a second amou chickflick91 7 5,492 Sep-26-2017, 05:13 PM
Last Post: chickflick91
  Amount of letters in a inputted string? CyanSupreme 3 3,582 May-10-2017, 09:40 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020