I think it should be another problem because I have a file where I
initialize all the tables, so that file contains all the tables. The
tables are created properly, but when I try to create a Screen object
(the main class, Screen -> CRM -> CRMContactInformation), I get this
error:

UnmappedClassError: Class 'Table('crm_contact_informations',
MetaData(None), Column('id', Integer(), ForeignKey('crms.id'),
table=<crm_contact_informations>, primary_key=True, nullable=False),
Column('owner', String(length=50, convert_unicode=False,
assert_unicode=None, unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('owner_phone',
String(length=20, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('owner_email',
String(length=50, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('store_manager',
String(length=50, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('store_phone',
String(length=20, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('store_email',
String(length=50, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('it_manager',
String(length=50, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('it_manager_phone',
String(length=20, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), Column('it_manager_email',
String(length=50, convert_unicode=False, assert_unicode=None,
unicode_error=None, _warn_on_bytestring=False),
table=<crm_contact_informations>), schema=None)' is not mapped

On Oct 25, 3:58 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> all modules which include mapped classes must be imported before you attempt 
> to initialize the mappings.  If class A references "B", but "class B" doesn't 
> exist, you get errors like that, so importing the modules that contain both 
> class A and B solves the issue.
>
> On Oct 25, 2010, at 2:55 PM, Alvaro Reinoso wrote:
>
> > Hello,
>
> > I get errors when I try to create tables one to one relation. Screen
> > contains crm and crm contains more classes. The relation is one to one
> > between crm, so I want to use the screen id as primary key in crm. And
> > the relation is one to one between crm and some classes, I just added
> > one class as example, so children of crm must contain a screen id as a
> > primary key. When I try to make the last relation, it's when it
> > breaks. I tried to use both, crm id and screen id.
>
> > I didn't work. I get errors such as, "UnmappedClassError" when I try
> > to use crm id in ContactInformation, and "Could not determine join
> > condition between parent/child tables on relationship
> > CRM.contactInformation. Specify a 'primaryjoin' expression. If this is
> > a many-to-many relationship, 'secondaryjoin' is needed as well" when I
> > try to use screen id in ContactInformation.
>
> > These are my classes:
>
> > class Screen(rdb.Model):
> >        """Set up screens table in the database"""
> >        rdb.metadata(metadata)
> >        rdb.tablename("screens")
>
> >        id = Column("id", Integer, primary_key=True)
> >        title = Column("title", String(100))
> >        ....
>
> >        crm = relationship("CRM", uselist=False, backref="screens")
>
> > class CRM(rdb.Model):
> >    """Set up crm table in the database"""
> >    rdb.metadata(metadata)
> >    rdb.tablename("crms")
>
> >    id = Column("id", Integer, ForeignKey("screens.id"),
> > primary_key=True)
>
> >    contactInformation = relationship("crm_contact_informations",
> > uselist=False, backref="crms")
> >        ....
>
> > class CRMContactInformation(rdb.Model):
> >    """Set up crm contact information table in the database"""
> >    rdb.metadata(metadata)
> >    rdb.tablename("crm_contact_informations")
>
> >    id = Column("id", Integer, ForeignKey("screens.id"),
> > primary_key=True)
> >    owner = Column("owner", String(50))
> >       ...
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "sqlalchemy" group.
> > To post to this group, send email to sqlalch...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > sqlalchemy+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to