Hello everyone, I have been trying to create a model for my database, with no luck so far. I am using SQLAlchemy 1.2.10 together with PyMySQL 0.9.2 to connect to a MariaDB database.
A description of the database model: Table A (components) *id brand status* N1 br3 free N2 br2 used N3 br2 used N4 br3 used N5 br2 used N6 br3 used N7 br2 used Table B (device1) *id comp1 comp2* 2 N2 N3 Table C (device2) *id comp1 comp2* 6 N4 N5 Table D (device3) *id comp1 comp2*1 N6 N7 So there are two foreign keys pointing to the same table (A) and column for all the other three tables, and every item on table A can only be assigned to a singe component column of a single table B, C or D. Ideally what I would like to achieve is something like this: component1 -> <N2 br2 used> component1.deviceInstalled -> <2 N2 N3> (from table B) component2 -> <N4 br3 used> component2.deviceInstalled -> <6 N4 N5> (from table C) I tried following the guidelines in Multiple Join Paths <http://docs.sqlalchemy.org/en/latest/orm/join_conditions.html#handling-multiple-join-paths>, still got ambiguous foreign keys error. As far as the relationship *deviceInstalled, *I have not managed to find somewhere how to implement that, since it has to span across three tables. My working but incomplete code <https://pastecode.xyz/view/59c02f2f> at the moment, with all the failed attempts removed. Any help would be very much appreciated, as I have been trying for a couple of days with no luck! Thank you -- 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.