You're totally correct. This is why I said "but please find out what pyodbc 
uses" :)

sqlite3 uses %s

On Wednesday, December 5, 2012 3:46:01 PM UTC-8, Dennis Lee Bieber wrote:
>
> On Wed, 5 Dec 2012 13:13:31 -0800 (PST), Chris Cogdon 
> <[email protected]<javascript:>> 
>
> declaimed the following in gmane.comp.python.django.user: 
>
>   
> > Good: 
> > 
> > cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad200000 as 
> x, 
> > tttcmf200000 as y WHERE (x.t_name = y.t_name) AND (x.t_user = %s)", ( 
> form, 
> > ) ) 
> > 
> > Note that we are no longer using the python % operator. %s here is 
> specific 
> > to db-api2, but please find out what pyodbc requires. it could be %s, 
> could 
> > be ?, or something else. 
>
>         DB-API2 does NOT mandate using %s -- that is just one of something 
> like four or five permitted styles; the style choice is determined by 
> the actual adapter used. 
>
>         From PEP 249: 
>
> >         paramstyle 
> >           
> >             String constant stating the type of parameter marker 
> >             formatting expected by the interface. Possible values are 
> >             [2]: 
> > 
> >                 'qmark'         Question mark style, 
> >                                 e.g. '...WHERE name=?' 
> >                 'numeric'       Numeric, positional style, 
> >                                 e.g. '...WHERE name=:1' 
> >                 'named'         Named style, 
> >                                 e.g. '...WHERE name=:name' 
> >                 'format'        ANSI C printf format codes, 
> >                                 e.g. '...WHERE name=%s' 
> >                 'pyformat'      Python extended format codes, 
> >                                 e.g. '...WHERE name=%(name)s' 
> > 
>
>         MySQLdb uses %s (MySQL did not have prepared statements prior to 
> v5; 
> everything was sent as fully formatted statements, and MySQLdb uses 
> Python string interpolation to generate the statements -- after passing 
> each parameter through a function that escapes special characters and 
> wraps SQL quotes around it). [probably works with "pyformat" too] 
>
>         SQLite3 uses ? 
> -- 
>         Wulfraed                 Dennis Lee Bieber         AF6VN 
>         [email protected] <javascript:>    
> HTTP://wlfraed.home.netcom.com/ 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Jm46rqwyFIoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to