Hey Jonathan,

Try this:
   Column('data', String(250), default=func.current_timestamp() + '12 hours')

Also, see attached sample for postgresql.
-G

On Thursday, May 11, 2006, 11:09:41 PM, you wrote:

> I'm trying to get SQLalchemy to set this as the insert value:

>      Column( "timestamp_expires", DateTime, nullable=False ,  
> default="NOW() + INTERVAL '12 hours'") ,

> the db looks like this:

>         Column        |            Type             |                
> Modifiers
> ---------------------+----------------------------- 
> +----------------------------------------
> timestamp_expires   | timestamp without time zone | default (now() +  
> '12:00:00'::interval)

> i'm not getting some sort of quoting right.  can someone point me in  
> the right direction?




> | - - - - - - - - - - - - - - - - - - - -
> | RoadSound.com / Indie-Rock.net
> | Collaborative Online Management And Syndication Tools
> | - - - - - - - - - - - - - - - - - - - -






> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
import sys
import time

from sqlalchemy import *

engine = create_engine('postgres', {'database':'test', 'host':'localhost', 
'user':'xxx', 'password':'xxx'}, echo=True, echo_uow=True)

conn = engine.connection()

class Primary(object):
        pass

try: 
   pri_t = Table('primary_table', engine,
        Column('id', Integer, primary_key=True),
        Column('data', String(250), default=func.current_timestamp() + '12 
hours'),
        Column('tmp', Integer)
        )
   pri_t.create()

   pri_t.insert().execute(
      {'tmp':1})
   time.sleep(1)
   pri_t.insert().execute(
      {'tmp':2})
   time.sleep(1)
   pri_t.insert().execute(
      {'tmp':3})
   time.sleep(1)
   pri_t.insert().execute(
      {'tmp':4})

   Primary.mapper = mapper(Primary, pri_t)

   p1 = Primary.mapper.select_by(tmp=1)[0]
   p2 = Primary.mapper.select_by(tmp=2)[0]
   p3 = Primary.mapper.select_by(tmp=3)[0]

   # Prints:
   # 1 2006-05-12T11:56:01.500000+03:00
   # 2 2006-05-12T11:56:02.522000+03:00
   # 3 2006-05-12T11:56:03.533000+03:00
   print p1.id, p1.data
   print p2.id, p2.data
   print p3.id, p3.data

finally:
   pri_t.drop()

Reply via email to