User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Python - SQLite - Tuple Variables Page [1]  
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

Cherokee
All American
8264 Posts
user info
edit post

So apparently tuples have to be referenced like arrays, so basically changing row to row[0] fixes it.

10/27/2017 4:03:01 PM

BigMan157
no u
103352 Posts
user info
edit post

glad i could help

10/27/2017 4:25:52 PM

V0LC0M
All American
21263 Posts
user info
edit post

my work here is done

10/27/2017 4:49:23 PM

wdprice3
BinaryBuffonary
45908 Posts
user info
edit post

Next time you need to download some datas from me, just shoot me a DM and I'll get up with you offline.

10/27/2017 7:10:51 PM

Novicane
All American
15408 Posts
user info
edit post

HR uses salesforce to store your pay info. probably why.

10/28/2017 7:16:28 AM

 Message Boards » Tech Talk » Python - SQLite - Tuple Variables Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.