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
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users