python - SQLAlchemy-friendly UPDATE instead of INSERT trigger -


i have authtoken table associated authtokenhist table record state changes in authtoken. make transparent model's user there archiving going on however. so, ideally, create new authtokens using same pk of existing authtoken , database update row in authtoken , create new row in authtokenhist when authtoken has entry pk.

i realize i'm asking close upsert, i'm on old postgresql version no support upserts. also, sqlalchemy's point of view, user think they're constructing new authtoken when they're update-ing existing one.

i've tried doing insert trigger deletes existing authtoken, inserts row authtokenhist , returns new. can't past sqlalchemy session though prohibits having 2 objects same pk in same session

flusherror: new instance <authtoken @ 0x3f51150> identity key (<class 'models.authtoken'>, (15l, u'c41ffcc3-5dbc-4042-a990-0c 18020cf77b')) conflicts persistent instance <authtoken @ 0x3f61350>


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -