[python-win32] How to specify parameters in a query using odbc
Tim Roberts
timr at probo.com
Tue Feb 1 19:14:24 CET 2011
Tom Hawkins wrote:
>
>
>
> I’m trying to get data out of a MS SQL Server 2005 database from a
> Python 2.5 script, using the odbc module - I can’t easily get anything
> more up-to-date installed on this system.
>
> ...
>
> ...it works OK, but if I try to parameterise the query:Any idea what
> I’m doing wrong please? Apologies if I’ve missed something stupid. I
> get the same error if I only specify one of the parameters with %s and
> leave the other one literal, by the way.
There are, for reasons that have never been clear to me, three different
parameter substitution styles allowed by the Python dbapi
specification. The Win32 odbc module uses ? characters instead of %s.
A simple search-and-replace should solve your problem.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list