By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,533 Members | 1,334 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,533 IT Pros & Developers. It's quick & easy.

using array as execute parameter in dbapi

P: n/a
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

Jul 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This is a really neat trick.

Thank you very much.

Jul 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.