'many'  is the same as 'remote' in the example that you are thinking of, 
but it loses applicability if you are doing a one-to-one relationship.

Let me illustrate with the `remote` annotation, which is a corollary form 
of `remote_side` in the relationships API, and tends to be more clear:

(http://docs.sqlalchemy.org/en/latest/orm/relationship_api.html#sqlalchemy.orm.relationship.params.remote_side)

Let's say you a self-referential table like the following:

    CREATE TABLE node (
        id SERIAL PRIMARY KEY
        id_parent INT REFERENCES node(id)
    )


if we want to make a sqlalchemy class that describes this with a 
relationship, we need to use `remote` or `remote_side` to indicate how 
columns on the object we fetch  match up to the objects it is related to

the sqlalchemy class might look like this:

     class Node(Base):
         id = Column(Integer, primary_key=True)
         parent_id = Column(Integer, nullable=True, ForeignKey('node.id'))

         parent = relationship("Node", primary_join=
"Node.parent_id==remote(Node.id)", uselist=False)
         child = relationship("Node", primary_join=
"Node.id==remote(Node.parent_id)", uselist=False)



this is basically the same example as in the self_referential docs 
(http://docs.sqlalchemy.org/en/latest/orm/self_referential.html), just 
using the alternate syntax and specifying  a one-to-one.  

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