There are many good examples of implementing many to many via a join table.

I'm not sure if I'm being lazy, or just using this as an opportunity to 
learn more sqlalchemy, but I'm trying to implement a shortcut from long a go

I know this approach requires a much slower query but these are tiny tables 
and they are cached at application startup, so I'm not concerned with 
performance.

I have two tables:

class SuperType(Base):
    '''
    creates groups of type recs
    '''
    __tablename__ = 'stp_super_type'
    stp_name = Column(String(50), nullable=False)
    stp_bit = Column(Integer, nullable=False, unique=True)   #  holds a 
unique bit-val for each record (2,4,8, 16,32, 64, etc)
    
*    types = relationship("Type",*
*                         order_by="asc(Type.typ_order)",*
*                        
 primaryjoin="SuperType.stp_bit.op('&')(Type.typ_stp_bits)==SuperType.stp_bit",*
*                         backref="stype"*
*                         )*

class Type(Base):
    '''
    types for many other recs throughout the system
    '''
    __tablename__ = 'typ_type'
    typ_name = Column(String(50), nullable=False)
    typ_stp_bits = Column(Integer, nullable=False)  # 
 ForeignKey(SuperType.stp_bit)
    typ_order = Column(Integer, nullable=False)


"id" is the pkey for each table and is generated in the Base

typ_stp_bits would hold a value such as  38 (2 or 4 or 32) to indicate it 
is a child (applicable within) those THREE super-type classes....
Hope that makes sense

How do I properly specify this relationship?
I'm getting a complaint that there is no foreign key defined on the 
Type/child table....

Thanks,
D

-- 
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to