I got a solution. Thanks to Michael. Here is what he suggested. *****
You use the Column object: from myproject.model import sometable someothertable = Table('someothertable', metadata, Column('foobar', Integer, ForeignKey(sometable.c.foobar)) as you can see the common theme in both cases is that one project has to get at the model of the other one - either the metadata object, or the table/column object (you can get at the metadata of any table using Table.metadata). The problem you're laying out is essentially one of one project having a dependency on the other, so unless you wanted to redefine the same Table objects as are in the first project as in the second project, you'd have an import dependency from the first one to the second. as far as importing modules across Turbogears projects, you'd have to ask on their list how that might be accomplished. ***** Both the ways work. :) Just that I will have to maintain a fixed relative path between the two packages and append the location of one pkg to sys.path while accessing its model from the other. JV On Nov 5, 6:40 am, JV <[EMAIL PROTECTED]> wrote: > Michael > > Can you elaborate a bit on how to do each of the thing you said - > metadata sharing between 2 separate Turbogears projects and placing > the actual column in the ForeignKey constructor, instead of string > 'table.column.id'. > > I read your earlier > discussionhttp://groups.google.com/group/sqlalchemy/browse_thread/thread/4db84b... > but I am still not clear on how to share the metadata. The only way I > can think of is to import the metadata object from one model1 to > model2, but that shall require the two pkgs to be present in fixed > relative positions. I don't see a common module where I can keep the > metadata object and use it in either pkg. > > JV > > On Nov 4, 6:19 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > either share the same MetaData object across those two models, or > > place the actual Column object instead of a string in the ForeignKey() > > constructor. > > > On Nov 4, 2008, at 7:16 AM, JV wrote: > > > > Hi > > > > How can I have a foreign key reference between the models of two > > > different TurboGears projects? > > > I am using sqlalchemy. > > > > JV --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---