[sqlalchemy] Re: Self Join

2009-09-17 Thread Michael Bayer
Paulo Aquino wrote: > On Tue, Sep 15, 2009 at 5:53 AM, Michael Bayer > wrote: > >> >> Paulo Aquino wrote: >> > I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid >> > products, a product is valid if it has both a valid 'Selling' and >> 'Buying' >> > ProductPrice type. A ProductP

[sqlalchemy] Re: Self Join

2009-09-16 Thread Paulo Aquino
On Tue, Sep 15, 2009 at 5:53 AM, Michael Bayer wrote: > > Paulo Aquino wrote: > > I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid > > products, a product is valid if it has both a valid 'Selling' and > 'Buying' > > ProductPrice type. A ProductPrice is valid if the valid_from

[sqlalchemy] Re: Self Join

2009-09-16 Thread Paulo Aquino
On Tue, Sep 15, 2009 at 5:53 AM, Michael Bayer wrote: > > Paulo Aquino wrote: > > I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid > > products, a product is valid if it has both a valid 'Selling' and > 'Buying' > > ProductPrice type. A ProductPrice is valid if the valid_from

[sqlalchemy] Re: Self Join

2009-09-14 Thread Michael Bayer
Paulo Aquino wrote: > I have 2 tables 'Product' and 'ProductPrice'. I want to get all valid > products, a product is valid if it has both a valid 'Selling' and 'Buying' > ProductPrice type. A ProductPrice is valid if the valid_from date <= > date.today() and valid_to >= date.today(). > > Product T

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Michael Bayer
page 199 of the SQLAlchemy oreilly book talks about association proxy ;) On Feb 25, 2009, at 6:12 PM, Stephen Telford wrote: > Okay, that sounds like a plan but., not to sound too much like a > broken record, does anyone have an -actual- example ? looking at > pages with a lot of API's is n

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Stephen Telford
and of course, both the passwords -are- the same (duh ;) .. the 'get()' works fine (obviously ;) Regards Stef On Wed, Feb 25, 2009 at 7:53 PM, Stephen Telford wrote: > Thank you Bobby!! That does make things more easier, and it shows then that > I am being a -real- moron here.. > > from sqlalche

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Stephen Telford
Thank you Bobby!! That does make things more easier, and it shows then that I am being a -real- moron here.. from sqlalchemy import * from sqlalchemy.orm import sessionmaker, mapper, relation meta = MetaData() meta.bind = 'postgres://root:sxta...@192.168.2.198/compass_master' engine = create_eng

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Bobby Impollonia
I am doing something similar. The following code works for me in SQLA .4.8 class Foo(Base): __tablename__ = 'foo' id = Column(Integer, primary_key=True) bar_table = Table('bar', Base.metadata, Column('parent_id', Integer, ForeignKey('foo.id'), nullable=False), Column('child_id', I

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Stephen Telford
Okay, that sounds like a plan but., not to sound too much like a broken record, does anyone have an -actual- example ? looking at pages with a lot of API's is not really going to help me too much :( This maybe slightly off-topic and it's really NOT meant as flamebait but.. I remember a while ago p

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Michael Bayer
check out the association proxy extension if you're looking to have "Bar" be "hidden" as an association object. it will ultimately use Foo/Bar for querying but attribute access would be proxied through the names you confgure. On Feb 25, 2009, at 4:11 PM, Stephen Telford wrote: > Hello Az

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread Stephen Telford
Hello Az, Yes, Bar is the association table of Foo to Foo. In essence, this is a self join through a join table.. I have tried and hit my head on this for (quite literally) hours. In the end, and for the record, I ended up creating a method on the model itself such as ; def children(self):

[sqlalchemy] Re: Self Join via Join Table ?

2009-02-25 Thread az
u mean, the Bar is an association table of Foo to Foo? u have to use secondary_table and/or secondary_join in the relation setup. And probably specify remote_side or it may not know which Foo is what. On Wednesday 25 February 2009 03:39:20 Stef wrote: > Hello Everyone, >First of all, kudos