I want to write a function that I can use like this
>>> update_foo(foo_id=1, colA=11)
and it do this internally:
cursor.execute("""
update foo
set colA = (%s)
where foo_id (%s)""", [11, 1])
And I want to pass in more than just a single column to update, like this, too:
>>> update_foo(foo_id=1, colA=11, colB=12, colC=13)
and it should do this:
cursor.execute("""
update foo
set
colA = (%s),
colB = (%s),
colC = (%s)
where foo_id (%s)""", [11, 12, 13, 1])
I'm having a really hard time doing this without building up strings
and then appending them together. Is there some better way?
Thanks in advance.
--
W. Matthew Wilson
matt(at)tplus1(dot)com
http://tplus1.com