Sqlalchemy as well as psycopg2 understands datetime.timedelta(), the cast is 
generated for you.  No custom SQL needed.

Sent from my iPhone

On Nov 8, 2012, at 5:06 AM, Chris Withers <[email protected]> wrote:

> Hi All,
> 
> What's the "right" way to do a query such as the following using the orm 
> layer?
> 
> select * from event where date < now() - '3 years'::interval
> 
> Related: is there any intergration-testing-ish way to get now() to return a 
> specific value in postgres, rather than the real now?
> 
> cheers,
> 
> Chris
> 
> -- 
> Simplistix - Content Management, Batch Processing & Python Consulting
>            - http://www.simplistix.co.uk
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to