G
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
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