Hi
I've recently used sqlacodegen

When I try and run against the generated code it get this  message that 
I've been unable to fix:

Could not determine join condition between parent/child tables on 
relationship Workgrp.usrmst - there are multiple foreign key paths linking 
the tables. Specify the 'foreign_keys' argument, providing a list of those 
columns which should be counted as containing a foreign key reference to 
the parent table.

I'm wondering if someone can shed some light:

Here is the generated code for the relevant tables causing the issue:

class Workgrp(Owner):
    __tablename__ = 'workgrp'

    workgrp_id = Column(ForeignKey('owner.owner_id'), primary_key=True)
    workgrp_prntid = Column(Numeric(scale=0, asdecimal=False))
    workgrp_name = Column(String(256))
    workgrp_desc = Column(String(4000))
    workgrp_owner = Column(ForeignKey('usrmst.usrmst_id'))
    workgrp_lstchgtm = Column(DateTime, index=True)
    workgrp_externid = Column(String(20))
    workgrp_profile = Column(Text)
    workgrp_usrmodtm = Column(DateTime)

    usrmst = relationship('Usrmst')


class Usrmst(Owner):
    __tablename__ = 'usrmst'
    __table_args__ = (
        Index('usrmst_ak1', 'usrmst_domain', 'usrmst_name'),
    )

    usrmst_id = Column(ForeignKey('owner.owner_id'), primary_key=True)
    usrmst_domain = Column(String(256))
    usrmst_name = Column(String(256), nullable=False)
    usrmst_fullname = Column(String(1024))
    usrmst_desc = Column(String(4000))
    usrmst_phoneno = Column(String(40))
    usrmst_pagerno = Column(String(40))
    usrmst_email = Column(String(1024))
    usrmst_emailtype = Column(Numeric(scale=0, asdecimal=False))
    secmst_id = Column(ForeignKey('secmst.secmst_id'))
    lngmst_id = Column(ForeignKey('lngmst.lngmst_id'))
    usrmst_password = Column(String(1024))
    usrmst_externid = Column(String(20))
    usrmst_suser = Column(String(1))
    usrmst_lstchgtm = Column(DateTime, index=True)
    usrmst_orapassword = Column(String(144))
    usrmst_wingroup = Column(String(1))
    usrmst_tmpacct = Column(String(1))
    usrmst_profile = Column(Text)
    usrmst_usrmodtm = Column(DateTime)
    usrmst_principal = Column(String(256))
    usrmst_keytab = Column(String(4000))

    lngmst = relationship('Lngmst')
    secmst = relationship('Secmst')

I've looked at the SQLAlchemy docs, and tried things with foreign_keys, 
primaryjoin, 
http://docs.sqlalchemy.org/en/latest/orm/relationship_api.html#sqlalchemy.orm.relationship.params.foreign_keys
http://docs.sqlalchemy.org/en/latest/orm/join_conditions.html#relationship-custom-foreign

 But ended up with messages like '
Table' object has no attribute 'usrmst_id'
AttributeError: 'Table' object has no attribute 'workgrp_owner'

Also for  Mike Bayer: Why is there no consistency in naming within 
SQLAlchemy?:
foreign_keys uses underscore
primaryjoin doesn't

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to