Re: using array as execute parameter in dbapi

2006-07-22 Thread gglegrp112
This is a really neat trick.

Thank you very much.

-- 
http://mail.python.org/mailman/listinfo/python-list


using array as execute parameter in dbapi

2006-07-21 Thread gglegrp112
Is it possible to send an array as a parameter for an execute method in
dbapi2 module?


I'm using adodbapi and try to perfrom the following SQL query:
 select * from item where storeid in ('01', '02')

When I use direct string formating it works:

 a=('01','02')
cur.execute('select * from item where storeid in %s' % a.__repr__())

but trying to use parameter does not work:

 cur.execute('select * from item where storeid in ?', a)
 cur.execute('select * from item where storeid in ?', (a,))
 cur.execute('select * from item where storeid in ?', ([a],)

and even this does not work:
 cur.execute('select * from item where storeid in ?', a.__repr__())
 cur.execute('select * from item where storeid in ?',
(a.__repr__(),))

surprisingly, this get executed be returns wrong result:
 cur.execute('select * from item where storeid in (\'?\'),
','.join(a))
I guess the question mark gets escaped by the quotes the parameter is
ignored.

Regards,

Magdy Salam

-- 
http://mail.python.org/mailman/listinfo/python-list