|
From: Dave P. <dpo...@te...> - 2003-08-01 19:42:18
|
Thanks, that did it!
import SQLObject.SQLBuilder
Records.expires = func.NOW() + SQLBuilder.SQLConstant("INTERVAL 30 DAY")
:)
On Fri, 2003-08-01 at 14:35, Ian Bicking wrote:
> Oops, that should have been
> SQLObject.SQLBuilder.SQLConstant("INTERVAL 30 DAY")
> -- you could also register something like mx.DeltaDateTime as a type,
> and convert it that way.
>
> Good luck, I'm off...
> Ian
>
>
> On Fri, 2003-08-01 at 13:56, Dave Poirier wrote:
> > On Fri, 2003-08-01 at 10:40, Ian Bicking wrote:
> > > On Fri, 2003-08-01 at 08:18, Dave Poirier wrote:
> > > > I'm trying to create a record in a database with a 'expires' field,
> > > > which records are deleted whenever expires <= NOW(). I seem to have
> > > > difficulty grasping how I can generate a query similar to:
> > > >
> > > > UPDATE records SET expires = NOW() + INTERVAL 30 DAY;
> > > >
> > > > I've tried something like:
> > > >
> > > > Records.expires = func.NOW('INTERVAL 30 DAY')
> > > > Records.expires = func.NOW() + 'INTERVAL 30 DAY'
> > > > Records.expires = func.NOW() + '+ INTERVAL 30 DAY'
> > > > Records.expires = func.DATE_ADD(func.NOW(),'INTERVAL 30 DAY')
> > >
> > > func.NOW() + const('INTERVAL 30 DAY')
> >
> > The query being sent to MySQL is:
> >
> > UPDATE session SET expires = (NOW() + __call__('INTERVAL 30 MINUTE'))
> > WHERE id = 2
> >
> > MySQL complains with:
> >
> > ProgrammingError: (1064, "You have an error in your SQL syntax near
> > '('INTERVAL 30 MINUTE')) WHERE id = 2' at line 1")
> >
> >
> > -Dave
|