On Oct 25, 2016 5:53 PM, "Alfred Soeng" <[email protected]> wrote: > > Hi, > > If I want to map a struct to 2 tables who have mostly the same info but different format, is that feasible? > e.g > > struct T { > 1. id > 2. name} > > a_mapper = mapper(T, m1, properties={...}) > b_mapper = mapper(T, m2, properties={...}) > > I tried to specify the b_mapper to non-primary one, but when I run the b_mapper model, it's still contain the a_mapper mapping information. > Is there any way to do this? Or I should create 2 structs to map to 2 models.
The primary mapper will instrument the class with attributes corresponding to that primary table. This is basically the whole reason people map classes, to get that instrumentation. If you want the class to have totally different attributes per each table you would make a subclass per mapping and just map them separately. Whatever you want common between them goes on the base class. > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. > --- > You received this message because you are subscribed to the Google Groups "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
