(dictin,joiner=',')
| 2 | |
| 3 | # To Generate string |
| 4 | def Dict2Str(dictin,joiner=','): |
| 5 | # make dict to str, with the format key='value' |
| 6 | #tmpstr='' |
| 7 | tmplist=[] |
| 8 | for k,v in dictin.items(): |
| 9 | # if v is list, so, generate |
| 10 | # "k in (v[0], v[1], ...)" |
| 11 | if isinstance(v, (list, tuple)): |
| 12 | tmp = str(k)+' in ('+ ','.join(map(lambda x:'\''+str(x)+'\'',v)) +') ' |
| 13 | else: |
| 14 | tmp = str(k)+'='+'\''+str(v)+'\'' |
| 15 | tmplist.append(' '+tmp+' ') |
| 16 | return joiner.join(tmplist) |
| 17 | def gen_update(table,dicts,conddicts): |
| 18 | # conddicts maybe the Condition, in sql, where key='value' or key in (value) |
| 19 | # dicts are the values to update |
no test coverage detected