Converting from local -> UTC

M.-A. Lemburg mal at egenix.com
Fri Jul 18 11:48:19 EDT 2008


On 2008-07-18 05:28, Dennis Lee Bieber wrote:
> On Thu, 17 Jul 2008 20:26:11 -0300, "Gabriel Genellina"
> <gagsl-py2 at yahoo.com.ar> declaimed the following in comp.lang.python:
> 
> 
>> Note that I used %s everywhere (it's just a placeholder, not a format) and  
> 
> 	<cue the beer commercial>
> 
> 	Unfortunately, in the case of MySQLdb... It is both -- maybe that
> will change once MySQLdb gives up compatibility with MySQL 4.x by
> incorporating usage of prepared statements in place of a Python %
> interpolation.
> 
> 	It has to be %s as the adapter first converts to string, escapes,
> and quotes the arguments; regardless of native datatype they are strings
> when put into the SQL statement...

If you prefer a different parameter style, you could use mxODBC
and the MySQL ODBC drivers.

You'd then write:

query = "INSERT INTO image VALUES(?, ?, ?, ?)"

and avoid any confusion due to the parameter style looking a
lot like the Python string formatting markers (for obvious
reasons, since that's what the MySQLdb module uses internally).

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 18 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the Python-list mailing list