The tables don't exist yet. The Base.metadata.create_all(engine) is to
create them.

Thanks!

On May 30, 11:52 pm, Michael Bayer <mike...@zzzcomputing.com> wrote:
> This might be because the tables you're trying to reference are themselves 
> not InnoDB.  Try running DESCRIBE on the referenced tables at the MySQL 
> console to help confirm this, as well as the same CREATE TABLE statement 
> below.
>
> On May 30, 2012, at 11:31 PM, Jeff wrote:
>
>
>
>
>
>
>
> > Having difficulty creating a database that includes the following
> > plumbing:
>
> > class Base(object):
> >    id = Column(Integer, primary_key=True)
> >    __table_args__ = {'mysql_engine': 'InnoDB'}
>
> > Base = declarative_base(cls=Base)
>
> > class Event(Base):
> >   ....
>
> > Avalanche_Event_Association = Table('Avalanche_Event_Association',
> >    Base.metadata,
> >    Column('avalanche_id', Integer, ForeignKey('Avalanche.id')),
> >    Column('event_id', Integer, ForeignKey('Event.id')),
> >    mysql_engine='InnoDB')
>
> > class Avalanche(Base):
> >   ....
>
> > Doing Base.metadata.create_all(engine) yields:
>
> > OperationalError: (OperationalError) (1005, "Can't create table
> > 'alstottj.Avalanche_Event_Association' (errno: 150)") '\nCREATE TABLE
> > `Avalanche_Event_Association` (\n\tavalanche_id INTEGER, \n\tevent_id
> > INTEGER, \n\tFOREIGN KEY(avalanche_id) REFERENCES `Avalanche` (id), \n
> > \tFOREIGN KEY(event_id) REFERENCES `Event` (id)\n)ENGINE=InnoDB\n
> > \n' ()
>
> > Commenting out the line "mysql_engine='InnoDB'" removes the error and
> > the tables are all created, but the association table is now MyISAM.
>
> > I have some feelings on what could be causing the error, but they all
> > seem improbable. Thoughts?
>
> > --
> > 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 
> > 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 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