I think I am using the same declarative_base instance but it is still
making the tables in the wrong order.

My model is at:
http://bazaar.launchpad.net/~richies/hypernucleus-server/PylonsPortExperimental/files/head%3A/hypernucleusserver/model/

And here is what happens when I run: paster setup-app development.ini
http://pastebin.com/VuW7UK3B

The problem now appears at games.py which is very similar to the
dependencies.py model.
A declarative_base instance is created in meta.py and then all the
models import the instance from that.

The problem is also exacerbated by InnoDB which keeps referential
integrity.
I wanted to move to InnoDB for this very reason.

On Nov 5, 12:29 am, Gunnlaugur Briem <gunnlau...@gmail.com> wrote:
> Strictly that's not a query, it's a table definition. Do you mean that
> you are creating a declarative model class corresponding to this table
> definition? Posting your code would help more.
>
> You must define both tables on the same metadata instance (in
> declarative, that's typically done by having both model classes extend
> the same declarative_base instance). If you call create_all on that
> metadata instance, it does respect the dependency order. (Unless
> you've found a bug, which is unlikely for code that's as central and
> heavily used as this.)
>
> Seehttp://www.sqlalchemy.org/docs/orm/extensions/declarative.html---
> follow the beginning of that, and make sure both of your model classes
> extend the same Base instance.
>
> Regards,
>
> - Gulli
>
> On Nov 4, 10:51 pm, Richie Ward <rich...@gmail.com> wrote:
>
> > I am trying to run this query:
> > CREATE TABLE dependenciesbinary (
> >     id INTEGER NOT NULL AUTO_INCREMENT,
> >     dependency_mn VARCHAR(128),
> >     name VARCHAR(128),
> >     operatingsystem VARCHAR(128),
> >     architecture VARCHAR(128),
> >     PRIMARY KEY (id),
> >     FOREIGN KEY(dependency_mn) REFERENCES dependencies (modulename)
> > )ENGINE=InnoDB CHARSET=utf8
>
> > But create_all() is not creating the table "dependencies" before
> > "dependenciesbinary" which causes MySQL to error due to the missing
> > table.
>
> > Is there some way I can change the order of the create statements to
> > fix this?
>
> > I am using Declarative if that helps.

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