Hi,

I am trying to create a simple many-to-many relationship using
PostgreSQL in a specific schema ('cards'). I do it like this:

class BaseObject(object):
    id =  Column(Integer, primary_key=True)
    date_created = Column(DateTime)
    date_modified = Column(DateTime)

collection_cards = Table(
    'collection_cards', Base.metadata,
    Column('card_id', Integer, ForeignKey('cards.id')),
    Column('collection_id', Integer, ForeignKey('collections.id'))
    )

class Card(Base, BaseObject):
    __tablename__ = 'cards'

    content = Column(Text)

    def __init__(self):
        super(Card, self).__init__()

class Collection(BaseObject, Base):
    __tablename__ = 'collections'

    name = Column(String)

    def __init__(self):
        super(Collection, self).__init__()

    cards = relationship(Card, secondary=collection_cards)

...


Base.metadata.schema = "cards"
Base.metadata.create_all(engine)

and I get:

sqlalchemy.exc.NoReferencedTableError: Foreign key associated with
column 'collection_cards.card_id' could not find table 'cards' with
which to generate a foreign key to target column 'id'

Without the relationsip, the two tables are created just fine in the
specified schema. What I am doing wrong?

Thanks,

Stefan

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