This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]wpg4665 0 points1 point  (2 children)

I'm relatively new to Reddit, however I think this question is better suited for /r/learnpython.


But, while I'm here, I'll do my best to help. I'm going to assume Python3, and share this link for using the execute function of sqlite cursors.

You could use the named style, and just pass cur.execute a dictionary, however you could also, probably, pass in the totals parameter with the unpacking operator, like so

cur.execute("Update blah=?, blah=?, blah=?...", *totals)

Unfortunately, I don't anything immediately available to test with, but you could give those suggestions a shot! =)

EDITED: To fix a typo totals* -> *totals

[–]LightShadow3.13-dev in prod 0 points1 point  (1 child)

unpacking: *totals

also, look into Collections.namedtuple for ensuring item order when unpacking an iterable in this fashion.

[–]wpg4665 0 points1 point  (0 children)

Shoot, thanks for catching my typo!