[python-win32] adodbapi: using prepared statements

Vernon Cole vernondcole at gmail.com
Fri May 25 23:53:28 CEST 2012


On Fri, May 25, 2012 at 12:04 PM, Tim Roberts <timr at probo.com> wrote:

> Alan Trick wrote:
> > On Fri, May 25, 2012 at 10:18 AM, Tim Roberts <timr at probo.com> wrote:
> >> Is there any change if you use a tuple instead of a list?  That is:
> >>
> >>    cur.execute("select * from chiro1 where prefix = ?", ('LEG',))
> > I get an identital exception with a tuple. For what it's worth, the
> > value of cur.query is different, but I don't know if that has any
> > effect on anything. With a list, cur.query is set to "select * from
> > chiro1 where prefix = ?,parameters=['LEG']", with a tuple it's "select
> > * from chiro1 where prefix = ?,parameters=('LEG',)".
>
> I'd expect that.
>
> I am at a loss. The adodbapi code gives the OLE DB provider a first shot
> at processing the parameters.  If that fails, then the Python code does
> the processing itself.  My guess is that the OLE DB provider here is
> saying "it worked!", but isn't actually setting up the substitutions.
>
> --
> Tim Roberts, timr at probo.com
>

My guess is that Tim's guess is correct.  ADO really doesn't do much to
remove the differences between SQL engines, and the adodbapi code blindly
hands stuff  to it.  If the FoxPro provider does not handle parameters, or
expects some format other than qmark, you might see an error like this
one.  Try setting adodbapi.adodbapi.verbose = 4 and see if that sheds any
light. Particularly look for the line that specifies 'error in COM
Refresh(), so adodbapi is building a parameter list'.
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120525/015fb0ce/attachment.html>


More information about the python-win32 mailing list