On Jul 14, 2006, at 9:29 AM, Jonathan LaCour wrote:

> I don't really know anything about how relationships are detected in
> SQLAlchemy when you use autoloading, so I am not sure if doing that
> part is possible, but using the existing infrastructure to load the
> columns themselves should be fairly straightforward.  Are there other
> people who want this?
>
> Michael -- could you enlighten me a little bit about how possible it
> would be to detect the relationships as well, and how this kind of
> thing is handled in regular SQLAlchemy?

when you get the Table object, you loop through its foreign_keys  
attribute and inspect the ForeignKey objects to see what table they  
are referring to.  then if you want to make relations out of all of  
those you would just use the relation() function once you've matched  
up each Table with its correseponding ActiveMapper class.

however, there are some problems that cant be solved with this,  
including that there is no way to detect a one-to-one relationship  
(since it looks identical to a one-to-many), youd definitely have a  
lot of difficulty properly detecting self-referential relationships,  
and it also isnt going to work for tables that have an inheritance  
relationship to each other (since those also look like one-to-many  
relationships).




-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to