Yes, you can have the same class be associated with different tables
at different times.

Sqlalchemy uses a 'maper' to associate a class with a table. You can
define multiple mappers for the same class that map it to different
tables. One of these will be the primary mapper and will be used by
default when you don't specify which mapper to use. To use the other
mapper, you use the keyword argument entity_name and specify the
mapper by name. Most session functions support that keyword arg.

Here is the documentation:
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_multiple

On Mon, Apr 7, 2008 at 9:37 AM, GK <[EMAIL PROTECTED]> wrote:
>
>  This is another "I'm new to SQLAlchemy" kind of question...
>
>  I have two datasets that have exactly the same structure, and I wish
>  to create separate database tables for these that are mapped to/from
>  the structure of same underlying Python class.  I looked for
>  discussion of this in the SQLAlchemy manual, but the references I
>  found (e.g. [1]) seem to discuss spreading a class over several tables
>  rather than multiple instances/datasets.
>
>  It appears that the mapper structure always associates a given python
>  class with a single table.  Is this correct?
>
>  The pattern I'm contemplating to support multiple datasets is to
>  define a subclass of the main class for each one, then map each
>  subclass to its own table.  Is there a better way?
>
>  #g
>
>  [1] 
> http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_joins
>
>
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to