I am trying to use a table with a timestamp in PostgreSQL  8.0.3 with
no success. My definitions are as follows:

CREATE TABLE sessions (
sess_id           VARCHAR(128)    NOT NULL PRIMARY KEY,
sess_logon    TEXT                     NOT NULL,
sess_ts          TIMESTAMP WITH TIME ZONE DEFAULT current_timestamp,
FOREIGN KEY (sess_logon) REFERENCES users (usr_logon) ON DELETE
cascade ON UPDATE cascade,
) WITHOUT OIDS;

sessions = Table('sessions', db,
    Column('sess_id', Integer, primary_key=True),
    Column('sess_logon', String,  ForeignKey('users.usr_logon'),
nullable=False),
    Column('sess_ts', DateTime, nullable=True))

Session.mapper = mapper(Session, tables.sessions, properties={
    'secret': tables.sessions.c.sess_id,
    'logon': tables.sessions.c.sess_logon,
    'ts': tables.sessions.c.sess_ts,})

class Session(object):
    mapper = None
    def __init__(self, secret=None, logon=None, ts=None):
        self.secret = secret
        self.logon  = logon
        self.ts     = ts

I then run the following code in ipython:

objectstore.begin()
s = Session()
s.secret = 'notsosecret'
s.logon = 'someuser'
objectstore.commit()

The full trace is below, but the error is basically this:

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/databases/postgres.py
in convert_bind_param(self, value, engine)
TypeError: argument 1 must be DateTime, not None


The behaviour that I wanted to see is that the SA would save the
session and PG would create the timestamp automatically.

What am I doing wrong in terms of using SA?

-marek


----- MORE COMPLETE TRACE ------

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/mapping/objectstore.py
in commit(*obj)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/mapping/objectstore.py
in commit(self, *objects)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/mapping/objectstore.py
in execute(self)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/mapping/objectstore.py
in execute(self, trans)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/mapping/mapper.py in
save_obj(self, objects, uow)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/sql.py in
execute(self, *multiparams, **params)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/sql.py in
execute(self, *multiparams, **params)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/engine.py in
execute_compiled(self, compiled, parameters, connection, cursor, echo,
**kwargs)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/ansisql.py in
get_params(self, **params)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/sql.py in
typeprocess(self, value, engine)

/home/marek/build/bdist.linux-i686/egg/sqlalchemy/databases/postgres.py
in convert_bind_param(self, value, engine)
TypeError: argument 1 must be DateTime, not None
N�HY޵隊X���'���u���[�������
ަ�k��!���W�~�鮆�zk��C� [EMAIL PROTECTED],����a{�
��,�H��4�m�����Z��jY�w��ǥrg

Reply via email to