Re: [cx-oracle-users] Modifying fetched data python types for zope adaptor
Brought to you by:
atuining
From: Andy H. <and...@gm...> - 2006-11-09 21:54:25
|
One thought I had after getting some sleep is that passing in the types cx_Oracle normally returns means you end up constructing the returned object twice anyway and you lose some of the performance benefits of doing this. I'm not sure whether building a string to pass into settype is much less work or not. Andy > Which really is pretty much the same as your settype(cx_Oracle.DATETIME, > <YourTypeOrMethod>). I guess the one thing they do in common is pass a > string to the conversion method, although it'd probably be as simple to pass > cx_Oracles native value for the given type, i.e. a datetime (or > cx_Oracle.Date) for cx_Oracle.DATETIME and so on. After all if I'm defining > the conversion methods then I should know what I'd be getting. > > Thanks again in advance. Sorry for going on so long there. > > Andy > > > On 11/9/06, Anthony Tuininga <ant...@gm...> wrote: > > > > There is no way of hooking into the returning of date objects. You'll > > have to hook the entire result set. You can do that quite easily by > > subclassing cx_Oracle.Cursor and overriding fetchone(), fetchmany() > > and fetchall() to transform any datetime.datetime entities into Zopes > > DateTime objects. Clearly there is a performance penalty in doing > > this. If you can suggest an alternative that would eliminate the > > performance penalty I'd be happy to entertain it. Perhaps something > > along the lines of settype(cx_Oracle.DATETIME, <YourTypeOrMethod>) > > which would then call <YourTypeOrMethod> with a particular set of > > parameters? Any thoughts on this? > > > |