you might want to try defining the tables completely explicitly, i.e.  
without the autoload, to see if in fact the autoload is not allowing  
the ForeignKeys to get properly created.  (i.e. i might have to  
create more test cases for "autoload a table with overridden columns  
that contain foreign keys to each other").

but before you do that, you first want to spell "autoload" correctly  
on the "venues" table definition (and i might want to take some  
errant **kwargs catchalls away from the Table constructor to decrease  
errors like that).


On Sep 24, 2006, at 9:05 PM, [EMAIL PROTECTED] wrote:

> I'm just starting out with SQLAlchemy.  I have a preexisting MySQL  
> database
> with implicit foreign keys (no REFERENCES clauses were used).  I  
> thought
> that by relying on the defined metadata I'd be able to create Table  
> objects
> and just override the columns which are foreign keys, e.g.:
>
>     from sqlalchemy import *
>     db = create_engine('mysql://localhost/concerts')
>     metadata = BoundMetaData(db)
>     venues = Table('venues', metadata,
>                    Column('address', Integer, ForeignKey 
> ("addresses.id"),
>                           key='address', primary_key=False,
>                           nullable=False, hidden=False),
>                    autload=True)
>     addresses = Table('addresses', metadata,
>                       Column('city', Integer, ForeignKey("cities.id"),
>                              key='city', primary_key=False,
>                              nullable=False, hidden=False),
>                       autoload=True)
>     cities = Table('cities', metadata, autoload=True)
>
> The intent above is that venues.address references addresses.id and
> addresses.city references cities.id.  All other columns should be  
> defined as
> they appear in the metadata object.  Alas, I wind up with a venues  
> object
> which only defines the one column.
>
> What have I overlooked?
>
> Thx,
>
> -- 
> Skip Montanaro - [EMAIL PROTECTED] - http://www.mojam.com/
> "In China today, Bill Gates is Britney Spears.  In America today,  
> Britney
> Spears is Britney Spears - and that is our problem."  Thomas L.  
> Friedman in
> "The World is Flat"
>
> ---------------------------------------------------------------------- 
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to  
> share your
> opinions on IT & business topics through brief surveys -- and earn  
> cash
> http://www.techsay.com/default.php? 
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Sqlalchemy-users mailing list
> Sqlalchemy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to