Hi.
Using SQLAlchemy 0.2.7

Dealing with legacy data, I want to map an object to two table :

  READONLY is a read only table, where I find legacy records.
  READWRITE is a normal table, where I want to store new and updated
informations.

I thought that using a secondary mapper on READONLY was the solution :

class C_Individus(object):
    def __repr__(self):
        return "C_Individus %s" % (self.MATRICULE)

ro_table = Table('READONLY', metadata, autoload=True)
rw_table = Table('READWRITE', metadata, autoload=True)

pri_mapper = mapper(C_Individus, rw_table, primary_key = [rw_table.c.MATRICULE])
seq_mapper = mapper(C_Individus, ro_table, primary_key =
[ro_table.c.MATRICULE], non_primary=True)

This way, I can fetch data into C_Individus from READONLY and
READWRITE and create new C_Individus wich are stored in READWRITE on
session.flush()

However, any modification to an object from READONLY is lost : data
are not saved in READWRITE on session.flush()

Is it normal, or have I done something wrong ?

Is there a better solution, or should I try to abuse polymorphic
inheritance, to load data from an union of READONLY and READWRITE ?

Thanks for your help !

-------------------------------------------------------------------------
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

Reply via email to