On Thursday, 25 July 2013 11:39:23 UTC-4, Michael Bayer wrote:
>
> But your backend isn't doing this; if you were using Postgresql for 
> example, it should be returning a timedelta() already.  So perhaps this is 
> MySQL.   you'd need to make a TypeDecorator that receives this integer and 
> does what you want with it.  You'd emulate the "Epoch" decorator currently 
> illustrated at 
> http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.TypeDecorator:
>

Yeah, sorry for forgetting to mention the back end .. I'm using sqlite, so 
my datetime objects are being written as strings.  That's why I'm using 
strftime('%s', ...) to convert them to epoch seconds before doing 
arithmetic with them.

I think I understand the mechanism here... except that since this isn't a 
real type (there's no data store behind this) is process_bind_param() 
useful at all?

For process_result_value() I think I want something like:

def process_result_value(self, value, dialect):
   return datetime.timedelta(seconds=value)

... since it's seconds-since-epoch that I'm doing arithmetic with.

Thanks for the pointers!  Off to mess around with this and see what I get..
 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to