Hi,

I am trying to make deletes cascade from one table to another,  but
unfortunately the tables are in different databases.

<code>
metadata1 = BoundMetaData('mysql://host/db1')
metadata2 = BoundMetaData('mysql://host/db2')

jobs_table = Table('jobs', metadata1,
        Column('jobid', Integer, primary_key=True),
        autoload=True)

folders_table = Table('folders', metadata2,
                Column('client', Integer, nullable=False),
                Column('account', String(8), nullable=False),
                ForeignKeyConstraint(['client', 'account'], ['jobs.client_id',
'jobs.account']),
                autoload=True)

mapper(Job, jobs_table, properties = {'folder': relation(Folder,
cascade="all, delete-orphan")} )

session = create_session()
job_query = session.query(Job)
</code>

The error I get is this:
ArgumentError: Error determining primary and/or secondary join for
relationship 'Job.folder (Folder)'. If the underlying error cannot be
corrected, you should specify the 'primaryjoin' (and 'secondaryjoin',
if there is an association table present) keyword arguments to the
relation() function (or for backrefs, by specifying the backref using
the backref() function with keyword arguments) to explicitly specify
the join conditions. Nested error is "Table 'None.jobs' not defined"

I have also tried using
ForeignKeyConstraint(['client', 'account'], ['db1.jobs.client_id',
'db1.jobs.account'])
but still the same error.

Unfortunately, because of tons of legacy stuff, moving the folders
table is not an option.
Thanks ahead of time, I'd appreciate any suggestions or insights.

-Inno


--~--~---------~--~----~------------~-------~--~----~
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