Re: pyodbc utf-8
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 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 <ch...@cogdon.org>
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
wlf...@ix.netcom.com 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 django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home