Thank you for your response. I tried posting this before, but it
failed. Hopefully it won't double-post.
I still get a "can't adapt 'UPDATE..." error. Here is the table from
my schema:
------------------------------------------------
CREATE SEQUENCE user_change_num_seq INCREMENT BY 1 MINVALUE 0 NO
MAXVALUE CACHE 1;
CREATE TABLE user_change (
user_change_id integer unique DEFAULT
nextval(('user_change_id_seq'::text)::regclass) NOT NULL PRIMARY KEY,
user_change_num integer DEFAULT
nextval(('user_change_num_seq'::text)::regclass) NOT NULL, -- not
unique, one record per branch path
user_change_sequence integer DEFAULT NULL, -- if two or more
steps should be treated contiguously, this is set to the starting step
num
prev_change integer default NULL, -- previous change in the
user ordering.
next_change integer default NULL, -- next change in the user
ordering (changed by undo/redo).
orphaned boolean NOT NULL default false, -- orphaned change,
is part of a branch of orphaned changes occurring in ascending id
order.
rejected boolean NOT NULL default false, -- rejected change,
stands alone
username character varying(100), --REFERENCES credentials in
db_master database
change_type character varying(50), -- Currently defined
outside of the db schema.
snapshot_id integer default NULL, -- recover from snapshot if
'o'
dom_string character varying, -- DOM string as received from
the front end.
front_end_change_id character varying, -- generated and reused
by front end.
front_end_timestamp character varying, -- generated and reused
by front end.
before character varying default NULL, -- Rich Text Before
change.
after character varying default NULL, -- Rich Text After
change.
db_change character varying, -- q/insert/update commands run
to apply this change to the database.
change_date timestamp with time zone NOT NULL DEFAULT now(),
section_id integer default NULL
);
CREATE INDEX user_change_front_end_change_id_idx ON
user_change(front_end_change_id);
-- CREATE INDEX user_change_before_idx ON user_change(before);
-- CREATE INDEX user_change_after_idx ON user_change(after);
CREATE INDEX user_change_prev_chnage_idx ON user_change(prev_change);
CREATE INDEX user_change_next_chnage_idx ON user_change(next_change);
------------------------------------------------
Here's how I'm using the table in SqlAlchemy:
self.metadata = BoundMetaData('postgres://%s:[EMAIL PROTECTED]:%s/%s' %
('tp','tp',config.dbhost,config.db_port,cherrypy.session['dbname']))
user_change_db_obj=Table('user_change', self.metadata,
Column('id', Integer, primary_key=True),
Column('user_change_num',Numeric,PassiveDefault('')),autoload=True)
i =
user_change_db_obj.update(user_change_db_obj.c.user_change_num==change_num).execute(user_name=cherrypy.session['username'],prev_change=head.user_change_num,change_type=self.chgDesc,
dom_string=Handy.jsonize(self.onestep),
front_end_change_id=self.onestep['step']['fromId'],
front_end_timestamp=self.onestep['step']['time'],
before=self.before,after=self.after, section_id=self.section_id,
db_changes=self.tokenInstructions)
-----------------------
The update causes the exception. What am I missing?
Thank you in advance,
Gloria
On Jun 22, 11:47 am, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Jun 22, 2007, at 8:42 AM, Gloria wrote:
>
>
>
> > Hi all,
> > I have a Postgresql 8.2.4 table where more than one field auto-
> > increments. It looks like I need Passive defaults. Can someone show me
> > how to add passive defaults to an existing db schema, where
> > autoload=True. The doc glosses over this, and I can't pin down the
> > syntax.
> > Thank you,
> > Gloria
>
> http://www.sqlalchemy.org/docs/
> metadata.html#metadata_tables_reflecting_overriding
>
> illustrates how to place explicit Column objects in a Table, while
> also specifying "autoload=True". the table will be fully autoloaded,
> then the columns you've specified should override.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---