From: ASh on
Hi, please help me understand why am I getting error with this query


new_start_date = "NOW() - '29 days'::INTERVAL"
self.dyndb.orderdb.query('''update xxxx set creation_date
= %s
where id_order = %s''', (new_start_date, "123"))



....
psycopg2.DataError: invalid input syntax for type timestamp with time
zone: "NOW() - '29 days'::INTERVAL"


From: D'Arcy J.M. Cain on
On Tue, 30 Mar 2010 13:47:42 -0700 (PDT)
ASh <anton.shishkov(a)gmail.com> wrote:
> Hi, please help me understand why am I getting error with this query
>
>
> new_start_date = "NOW() - '29 days'::INTERVAL"
> self.dyndb.orderdb.query('''update xxxx set creation_date
> = %s
> where id_order = %s''', (new_start_date, "123"))

Put single quotes around the first %s in the query.

--
D'Arcy J.M. Cain <darcy(a)druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
From: ASh on
On Mar 31, 12:26 am, Philip Semanchuk <phi...(a)semanchuk.com> wrote:
> On Mar 30, 2010, at 4:47 PM, ASh wrote:
>
> > Hi, please help me understand why am I getting error with this query
>
> >            new_start_date = "NOW() - '29 days'::INTERVAL"
> >            self.dyndb.orderdb.query('''update xxxx set creation_date
> > = %s
> >            where id_order = %s''', (new_start_date, "123"))
>
> > ...
> > psycopg2.DataError: invalid input syntax for type timestamp with time
> > zone: "NOW() - '29 days'::INTERVAL"
>
> Hi Anton,
> It sounds to me like the problem is with your SQL rather than with  
> psycopg2 or Python. Try the query directly in Postgres -- does it work  
> there? If so, then your next step should be to ask on the psycopg2  
> mailing list that Google can find for you.
>
> Good luck
> Philip

sql itself is correct
From: ASh on
On Mar 31, 12:50 am, "D'Arcy J.M. Cain" <da...(a)druid.net> wrote:
> On Tue, 30 Mar 2010 13:47:42 -0700 (PDT)
>
> ASh <anton.shish...(a)gmail.com> wrote:
> > Hi, please help me understand why am I getting error with this query
>
> >             new_start_date = "NOW() - '29 days'::INTERVAL"
> >             self.dyndb.orderdb.query('''update xxxx set creation_date
> > = %s
> >             where id_order = %s''', (new_start_date, "123"))
>
> Put single quotes around the first %s in the query.
>
> --
> D'Arcy J.M. Cain <da...(a)druid.net>         |  Democracy is three wolveshttp://www.druid.net/darcy/               |  and a sheep voting on
> +1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.

Tried like you said, got this error:

psycopg2.ProgrammingError: syntax error at or near "NOW"
LINE 1: update orderdb.orders set creation_date = 'E'NOW() - ''29
da...
^
From: D'Arcy J.M. Cain on
On Tue, 30 Mar 2010 15:46:12 -0700 (PDT)
ASh <anton.shishkov(a)gmail.com> wrote:
> > >             new_start_date = "NOW() - '29 days'::INTERVAL"
> > >             self.dyndb.orderdb.query('''update xxxx set creation_date
> > > = %s
> > >             where id_order = %s''', (new_start_date, "123"))
> >
> > Put single quotes around the first %s in the query.
>
> Tried like you said, got this error:
>
> psycopg2.ProgrammingError: syntax error at or near "NOW"
> LINE 1: update orderdb.orders set creation_date = 'E'NOW() - ''29
> da...

Right. I misread it. Please show us the exact error that you get with
the original code.

--
D'Arcy J.M. Cain <darcy(a)druid.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.