Cherokee All American 8264 Posts user info edit post |
So I'm working on a project at work because they won't give me access to SalesForce backend.
I'm attempting to use Python to loop through and update data I've stored in an SQLite3 DB.
For some reason, trying to substitute a variable into the SELECT statement will not work. I've done a ton of Googling and ruled out all of the comma errors and such and am still not sure what's going on.
Roughly speaking:
---------------------------------------------------------------------------------------------- cur.execute("SELECT Number FROM UniqueList") PlaceHolder = cur.fetchall() for row in PlaceHolder:
cur.execute("SELECT Date FROM UniqueList WHERE Number = ?", row,)
print (Date) ----------------------------------------------------------------------------------------------
So when I run the above, it fails with some error. If I first define the tuple and run it, it fails. If I convert either row (from above) or the defined tuple into a string, the code executes but returns no data, just [].
If I substitute an actual number into the SELECT statement as opposed to a variable, it works perfectly and returns dates.
I feel like the problem either has to be a data type issue or some restriction with SQLite such as how you can't use a table name as a parameter (that is, as a substitute via variable).
Appreciate any help. 10/27/2017 2:41:02 PM |