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.)

See http://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