hi,
next construct make this error:
sqlalchemy.exc.NoReferencedTableError: Could not find table 'skupiny'
with which to generate a foreign key
and i dont find any idea, where is my bug.
-----------------------------------
engine = create_engine
("sqlite:///:memory:",echo=True,convert_unicode=False,
assert_unicode=False, encoding='utf-8')
meta = MetaData(engine)
# create a configured "Session" class
Session = sessionmaker(bind=engine)
session = Session()
Base = declarative_base()
sezony_key = Table('sezony_key', meta,
Column('skupina_id', Integer, ForeignKey('skupiny.id'),
primary_key=True),
Column('sezona_id', Integer, ForeignKey('sezony.id'),
primary_key=True))
class Skupina(Base):
__tablename__="skupiny"
id = Column(Integer,primary_key=True)
name = Column(Unicode(50))
hod = Column(Time)
den = Column(Integer,nullable=True)
pocet = Column(Integer)
vymazat=Column(Boolean,default=False)
def __init__(self, name):
self.name=name
class Sezona(Base):
__tablename__="sezony"
id = Column(Integer,primary_key=True)
name = Column(Unicode(50))
dfrom = Column(Date)
dto = Column(Date)
skupiny = relation('Skupina', secondary="sezony_key")
def __init__(self,name):
self.name=name
if __name__ == "__main__":
meta.create_all(engine)
Base.metadata.create_all(engine)
s=Skupina("s1")
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---