[DB-SIG] db module wrapper
randall at tnr.cc
Fri Aug 20 21:52:16 CEST 2004
Assume that the first item in the list is always sql. Is that a valid
Ian Bicking wrote:
> Just thought about it, how would you deal with:
> name = 'bob'
> query = ['select * from tname where col = ', name]
> The query is just two strings -- the first is a SQL expression, the
> second some data. But there's no way to tell that just from looking at
> the query list.
> Randall Smith wrote:
>> What do you think about Vernon Cole's idea with passing a query in as
>> a list. I thought about it and I'm starting to like it. Check this out.
>> l1 = ['harry', 'sam', 'charley']
>> l2 = [1, 2, 3]
>> query = "select * from tname where col1 = ", l1, " and col2 = ", l2
>> query = 
>> query.append('select * from tname where col1 = ')
>> query.append('and col2 = ')
>> Note: This is like executemany.
>> There is no need for parsing at all and the line breaking encouraged
>> by using a list makes for readable code.
>> What do you think?
More information about the DB-SIG