> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:sqlalch...@googlegroups.com] On Behalf Of Martijn Moeling
> Sent: 15 October 2009 15:38
> To: sqlalchemy@googlegroups.com
> Subject: [sqlalchemy] Re: Declerative Relation trouble
> 
> Hi Simon,
> 
> 
> (I do things a little different on the import side)
> Working example (very minimised):
> 
> 
> from sqlalchemy import 
> Integer,Column,DateTime,Unicode,UnicodeText,Boolean,ForeignKey
> ,Interval
> from sqlalchemy.ext.declarative import declarative_base
> import sqlalchemy.orm as orm
> Base = declarative_base()
> 
> 
> class Event(Base):
>     __tablename__       = "CalendarEvents"
>     Id                  = Column(Integer, primary_key=True)
>     CalendarId          = Column(ForeignKey('Calendars.Id'))
> 
> 
> class Calendar(Base):
>     __tablename__       = "Calendars"
>     Id                  = Column(Integer, primary_key=True)
>     UserId              = Column(Integer, index=True)
>     ProdId              = Column(Unicode(255))
>     Version             = Column(Unicode(5))
>     CalScale            = Column(Unicode(20))
>     Method              = Column(Unicode(10))
>     Events              = 
> orm.relation(Event,backref='Calendar')#,  cascade="all")
> 
> if __name__ == '__main__':
>    engine = create_engine('sqlite:///')
>    Base.metadata.create_all(bind=engine)
>    Session = orm.sessionmaker(bind=engine)()
> 
>    cal = Calendar()
> 
> when I run this I get:
> 
> 
> Traceback (most recent call last):
>   File "/var/www/PyWebOs/caltst.py", line 28, in <module>
>     cal = Calendar()
>   File "<string>", line 4, in __init__
>   File 
> "/usr/local/lib/python2.6/site-packages/sqlalchemy/orm/state.p
> y", line 71, in initialize_instance
>     fn(self, instance, args, kwargs)
>   File 
> "/usr/local/lib/python2.6/site-packages/sqlalchemy/orm/mapper.
> py", line 1810, in _event_on_init
>     instrumenting_mapper.compile()
>   File 
> "/usr/local/lib/python2.6/site-packages/sqlalchemy/orm/mapper.
> py", line 666, in compile
>     "Message was: %s" % mapper._compile_failed)
> InvalidRequestError: One or more mappers failed to compile.  
> Exception was probably suppressed within a hasattr() call. 
> Message was: One or more mappers failed to compile.  
> Exception was probably suppressed within a hasattr() call. 
> Message was: One or more mappers failed to compile.  
> Exception was probably suppressed within a hasattr() call. 
> Message was: Could not find table 'Calendar' with which to 
> generate a foreign key
> 
> 
> which is excacly the same as I got.....
> 
> 
> I have done so mutch in python/sqlalchemy that I feel 
> extremely stupid not to get this working, it might be just a 
> case of "overreading" the problem
> 
> 
> Martijn
> 

That script works for me (I needed to add 'create_engine' to the import
line) on SQLAlchemy 0.5.5. How are you running it?

Simon

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to