Fwd: Timestamp Query Parameters

From: Ari King <ari(dot)brandeis(dot)king(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Fwd: Timestamp Query Parameters
Date: 2014-03-13 21:40:52
Message-ID: CAPcS2agNgwVLNDgw0qVbsVzixSTpMKDFL3uLH557CdWJqX1dWA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: psycopg

Hi,

I'm just starting out with psycopg2. I'm trying to pass a timestamp query
parameter to an sql query. Unfortunately the constructed query returns
nothing, even though it should. The code follows; does anyone see what I'm
doing wrong?

date = datetime.now().strftime("%Y-%m-%d")
params = [datetime.strptime(date + " 00:00:00", '%Y-%m-%d %H:%M:%S'),
datetime.s
trptime(date + " 23:59:59", '%Y-%m-%d %H:%M:%S')]
print params
try:
query = """select * from timesheet
s where submitted=true and started_at between '%s' and '%s'"""
cursor.mogrify(query, params)

Thanks.

-Ari

Responses

Browse psycopg by date

  From Date Subject
Next Message Adrian Klaver 2014-03-13 21:57:30 Re: Fwd: Timestamp Query Parameters
Previous Message Adrian Klaver 2014-02-21 19:01:00 Re: how to pass in bind variables with cursor.copy_expert?