I get a similar result if I use psycopg2 directly: #!/usr/bin/python
import psycopg2 from datetime import datetime conn = psycopg2.connect('''dbname=testdb user=postgres host=localhost''') cur = conn.cursor() cur.execute("drop table if exists t0") cur.execute("create table t0(c0 timestamp(0) with time zone)") cur.execute("insert into t0 values(current_timestamp)") cur.execute("select c0 from t0 where c0 < %(bindArg)s - interval '1 hour'", {'bindArg':datetime.utcnow()}) On Fri, Apr 18, 2008 at 6:26 PM, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > On Apr 18, 2008, at 4:42 PM, Matthew Dennis wrote: > > > I'm using SA 0.4.3 and PostgreSQL 8.3.1 > > > > I'm new to SA, so perhaps I'm doing something wrong or just not > > understanding something, but I think SA is trying to treat my > > timestamps as intervals in some cases. If I run the equivalent > > (select c0 from t0 where c0 < current_timestamp - interval '1 hour') > > via psql, it works as expected. However, > > > > If I run: > > #!/usr/bin/python > > > > from datetime import datetime > > from sqlalchemy.sql import text > > from sqlalchemy import create_engine, MetaData > > > > engine = create_engine('postgres://[EMAIL PROTECTED]/testdb', > > encoding='utf-8') > > metadata = MetaData(bind=engine) > > > > engine.execute(text("drop table if exists t0")) > > engine.execute(text("create table t0(c0 timestamp(0) with time > > zone)")) > > engine.execute(text("insert into t0 values(current_timestamp)")) > > engine.execute(text("select c0 from t0 where c0 < :bindArg - > > interval '1 hour'"), bindArg=datetime.utcnow()) > > > > the text() above sends through the bind argument to psycopg2 directly, > which knows how to handle datetime objects. What happens if you test > with raw psycopg2 ? > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---