Hi,
I am using sqlalchemy for a while in a project.
The project has lots of models like User:
------------------------------------------------------------------------------
from mcmodel import MCModel
Base = declarative_base()
class User(MCModel, Base):
__tablename__ = 'users'
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.Unicode(12))
fullname = sa.Column(sa.Unicode(40))
password = sa.Column(sa.Unicode(20))
active = sa.Column(sa.Boolean())
type = sa.Column(sa.SmallInteger())
note = sa.Column(sa.Text())
date_created = sa.Column(sa.Date())
------------------------------------------------------------------------------
All of these models inherit from MCModel (nothing doing special).
I want to save all the changes done to a user in a seperate db table
like "_hist_users".
The new inserts do not need to be in the hist table.
When a user is updated, the old data of the user will be copied to the
hist table with a column declaring this is an update operation.
When a user is deleted, the old data of the user will be moved to the
hist table with a column declaring this is a delete operation.
With these operations, it is possible to know who modified what and
when.
How can i achieve in this?
By modifying the MCModel to enable all the models aware of history
backup?
Or using class sqlalchemy.orm.interfaces.MapperExtension.after_update
methods? (i do not know how)
Or anything else?
Thanks in advance.
Suha
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---