Thanks Michael,
I need a cross-dialect solution so if that's the best we have, I think I'll 
go with the inefficient load-everything-and-sort-in-python method :)

On Tuesday, June 9, 2015 at 9:32:03 PM UTC+3, Michael Bayer wrote:
>
>  you'd need to look into recursive querying.   PG can do this with CTEs:
>
> http://www.postgresql.org/docs/8.4/static/queries-with.html
>
> here's a tutorial that IMO goes way too fast and complicated, but SQLA can 
> do the SELECT part of this at least:
>
>
> http://schinckel.net/2014/11/27/postgres-tree-shootout-part-2%3A-adjacency-list-using-ctes/
>
>
>
> On 6/9/15 2:13 PM, Ofir Herzas wrote:
>  
>  I have a self referencing table like the following:
>
>  class Employee(Base):
>     __tablename__ = "t_employee"
>
>
>     id = sa.Column(BigInteger, sa.Sequence('%s_id_seq' % __tablename__), 
> primary_key=True, nullable=False)
>     manager_id = sa.Column(BigInteger, sa.ForeignKey("t_employee.id", 
> ondelete='SET NULL'))
>
>  
>
>  I want to select all rows ordered by their dependency (much like 
> metadata.sorted_tables does for tables). E.g - each manager should come 
> before his employees
>
>  What is the best way to achieve this (assuming the blunt 
> load-it-all-and-order-it is not the best method)?
>  -- 
> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>
>
>  

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to