[sqlalchemy] : Declarative and association object same model

2009-09-04 Thread Laurent Rahuel
Hi, I need to implement the storage of the neighborood of a place. I try to use Declarative and relation to get this done but it sounds like I missed something important I can not understand. Here are my models: neighbors_table = Table('neighbors', Base.metadata, Column('shop_id',

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread asrenzo
Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id == neighbors_table.place_id), secondaryjoin= (neighbors_table.neighbor_id == Place.id), secondary=neighbors_table) and the error is: sqlalchemy.exc.InvalidRequestError: When

[sqlalchemy] Is it possible to map more complex objects with a composite?

2009-09-04 Thread mgemmill
What would be the recommended method of mapping something like a Money class - objects that are a basic value + descriptor where the descriptor (in this example currency) is more than just a primitive variable? For example: class Currency(object): def __init__(self, code, descrip):

[sqlalchemy] left outer join on multiple columns (not primary keys)

2009-09-04 Thread Arno
I am trying to do an left outer join from two sql queries but cannot find how to join on multiple columns. I am using the outerjoin function. The only way I found was to use a text clause for the on clause. Basically, I have: q1 = create_sql1().alias('qleft') q2 = create_sql2().alias('qright') oj

[sqlalchemy] Re: left outer join on multiple columns (not primary keys)

2009-09-04 Thread Michael Bayer
Arno wrote: I am trying to do an left outer join from two sql queries but cannot find how to join on multiple columns. I am using the outerjoin function. The only way I found was to use a text clause for the on clause. Basically, I have: q1 = create_sql1().alias('qleft') q2 =

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Michael Bayer
asrenzo wrote: Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id == neighbors_table.place_id), secondaryjoin= (neighbors_table.neighbor_id == Place.id), secondary=neighbors_table) and the error is:

[sqlalchemy] Re: Is it possible to map more complex objects with a composite?

2009-09-04 Thread Michael Bayer
mgemmill wrote: What would be the recommended method of mapping something like a Money class - objects that are a basic value + descriptor where the descriptor (in this example currency) is more than just a primitive variable? For example: class Currency(object): def

[sqlalchemy] Re: left outer join on multiple columns (not primary keys)

2009-09-04 Thread Arno
On 4 sep, 16:26, Michael Bayer mike...@zzzcomputing.com wrote: Arno wrote: I am trying to do an left outer join from two sql queries but cannot find how to join on multiple columns. I am using the outerjoin function. The only way I found was to use a text clause for the on clause.

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Laurent Rahuel
Thanks Michael, Everything is OK now. Sorry for the typo, I was renaming my classes. Regards, Laurent Le 04/09/2009 16:30, Michael Bayer a écrit : asrenzo wrote: Here is a primaryjoin, secondaryjoin I tried without success: neighbors = relation(Place, primaryjoin=(Place.id ==

[sqlalchemy] Re: : Declarative and association object same model

2009-09-04 Thread Michael Bayer
Laurent Rahuel wrote: Thanks Michael, Everything is OK now. Sorry for the typo, I was renaming my classes. it wouldn't be tough for us to enhance declarative such that you can name Table objects in those strings as wellsince we have the MetaData available.I'll add a ticket.

[sqlalchemy] Re: left outer join on multiple columns (not primary keys)

2009-09-04 Thread Arno
On 4 sep, 16:26, Michael Bayer mike...@zzzcomputing.com wrote: Arno wrote: I am trying to do an left outer join from two sql queries but cannot find how to join on multiple columns. I am using the outerjoin function. The only way I found was to use a text clause for the on clause.

[sqlalchemy] distinct (or group by) with max in sqlalchemy - how to?

2009-09-04 Thread Nguyen, Thang P
Hi, I've recently started learning sqlalchemy. So far, I am able to do everything I needed with sqlalchemy query. Now, I am getting into a situation, and hope someone would give me a suggestion. Below is my question. My test table has two columns Name and Count Name Count A

[sqlalchemy] Re: Is it possible to map more complex objects with a composite?

2009-09-04 Thread mgemmill
Thanks for pointing me in the right direction Michael. On Sep 4, 7:34 am, Michael Bayer mike...@zzzcomputing.com wrote: mgemmill wrote: What would be the recommended method of mapping something like a Money class - objects that are a basic value + descriptor where the descriptor (in this