[Zope-DB] Question on ZSQL and Dates
M.-A. Lemburg
mal@lemburg.com
Thu, 24 Oct 2002 09:48:37 +0200
Charlie Clark wrote:
> On 2002-10-23 at 18:22:06 [+0000], you wrote:
>
>>Yes. sysdate is Oracle's way of saying "give me the current time
>>in your own format". Which database backend are you (currently ;-)
>>using ?
>
> MySQL and thanx to Michal, I've got it working
> does
> SELECT * from MyTable
> WHERE
> x <= y <= z
>
> really have to be replaced by
> SELECT * from MyTable
> WHERE
> x <= y
> AND
> y <= z
>
> SQL is worse than I thought. I guess I'm really spoilt by "growing up" with
> Python!
SQL was designed much earlier and they had no time machine ;-)
>>Also, what's the error message you get from Zope when you
>>try your solution ?
>
> Depends exactly what I'm doing. I quite often don't get an error message just
> garbage from the calculation. Database datetime values are returned nicely
> for display but useless for calculations... if I add or take something from
> them I get a float? back with a suspicious value like 19690512e8 + 5 for
> 1969/05/13. So Zope isn't giving me the datetime value back as an DateTime
> object.
That depends on the Zope DA you are using. The DA should return
a (Zope) DateTime instance for date columns.
>>One possibility is that the database expects a specific date
>>format and that Zope's DateTime objects don't use this per
>>default.
>
> That seems to be the case. This changes magically when mxDateTime is around
> apparently:
> "I was surprised by that because the other way (from MySQL to Zope)
> converts date/time/datetime values to DateTime objects if mxDateTime
> is available. Of course I expected that I can give DateTime objects to
> update methods too"
> in http://lists.zope.org/pipermail/zope-db/2002-May/000558.html
Ah, MySQL uses mxDateTime if its available. That's probably
what you're seeing here.
>>It's easy to install egenix-mx-base in Zope.
>
> I've got it installed and it's visible but I thought it would be nice to get
> Zope to use it instead of the built-in DateTime stuff. I tried doing this
> manually but wasn't getting anywhere fast.
That won't work because the Zope internals rely on the
Zope DateTime interface. mxDateTime provides a different
interface.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/