jangbagu / pypyodbc

Automatically exported from code.google.com/p/pypyodbc
0 stars 0 forks source link

Enhancement: Support for lists as SQL parameters #59

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

Let's say I have 20 fields and a bunch of data in list form. In order to do a 
massive update, a massive amount of typing would be required. You would need 
something like:

cursor.execute("UPDATE tablename SET field1=?, field2=?, field3=? ...... 
value[0], value[1], value[2]") .......etc.

I propose a means to do the following:

cursor.execute("UPDATE tablename SET fieldlist[]=? WHERE x=y", fieldvalues[])

or

cursor.execute("UPDATE tablename SET fieldlist[1:4]=? WHERE x=y", 
fieldvalues[1:4])

The lists would by necessity be the same length (or one would be ranged to 
match the other). The lists would also need be in the same order for 
appropriate iteration, and the values list would need to contain data 
appropriate for the fields specified. (e.g. no strings in a field meant for 
ints)

It's very limited in use, but could potentially save a lot of typing. If 
there's any interest in this feature, and I can figure out how to implement it, 
I'll be happy to handle the fix.

Original issue reported on code.google.com by icsnyde...@gmail.com on 7 Jan 2015 at 2:51