I'm running on 5.0.51a and InnoDB as well and have had no problems
creating references. Here's what I use:

referenced = Table('Referenced', self.metadata,
        Column('id', MSInteger(unsigned=True),
                primary_key=True),
        mysql_engine='InnoDB'
)
referencing = Table('Referencing', self.metadata,
        Column('referenced_id',         MSInteger(unsigned=True),
                ForeignKey('Referenced.id'),
        mysql_engine='InnoDB'
)

Simon

On 1 Okt., 14:59, GustaV <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm experiencing an issue on MySQL (5.0.51a) when sqlalchemy create
> the tables with foreign keys.
>
> The SQL issued :
> CREATE TABLE `referenced` (
> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY
> ) TYPE = InnoDB;
>
> CREATE TABLE `referencing` (
> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
> `f` INT NOT NULL,
> FOREIGN KEY(f) REFERENCES referenced(id)
> ) TYPE = InnoDB;
>
> I got an error (#1005 - Can't create table './seed-online/
> referencing.frm' (errno: 150) )... I solve this when I specify
> explicitly the foreign key being an index (looks like it is the
> "normal" way to do this)
>
> CREATE TABLE `referencing` (
> `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
> `f` INT NOT NULL,
> INDEX(f),
> FOREIGN KEY(f) REFERENCES referenced(id)
> ) TYPE = InnoDB;
>
> But I don't know how to tell sqlalchemy to explicitely set that index.
> On the other hand, at home (using wampserver2.0c, same version of
> MySQL) it works : it looks like the index is set automatically if not
> already set (I red this in the MySQL docs).
>
> So I'm looking for either :
> - an option to tell sqlalchemy to set the index explicitely
> - or, the option in MySQL to turn 'on' to have this INDEX
> automatically!
>
> Thanks a lot!
>
> Guillaume
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to