[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread svilen
well, i tried it manualy and it works (sqlite). here the eagerloading query: model-description (joined_inheritance): class A: name = Text() class B(A): address = reference( Adress) nom = reference( Nomerator) class C(A): pass select * from A left outer join B on A.db_id = B.db_id

[sqlalchemy] Re: filter() on inherited class doesn't point to the correct table

2008-01-15 Thread Alexandre Conrad
Michael Bayer wrote: that doesnt sound right. taking out select_table, and doing: print Media .query .select_from (media_table .join (catalog_table ).join (catalog_channel_table )).filter(CatalogChannel.c.id_channel==playlist.id_channel).all() leads to the SQL:

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-15 Thread Denis S. Otkidach
On Jan 11, 2008 8:41 PM, Michael Bayer [EMAIL PROTECTED] wrote: what that looks like to me is that you're attempting to query the database for object ID #1 using merge(). when you merge(), its going to treat the object similarly to how it does using session.save_or_update(). that is, it

[sqlalchemy] Re: Doing a dynamic Update

2008-01-15 Thread Mike
Rick, On Jan 10, 7:02 pm, Rick Morrison [EMAIL PROTECTED] wrote: For a stepwise migration from raw, SQL, it will probably be easier to get your mind around the SQL-expression side of the library, and then adopt ORM features as you feel comfortable with them. On the SQL-expression side of

[sqlalchemy] parent table

2008-01-15 Thread Alexandre da Silva
Hello all, Can I get the parent table from an inherited table? something like: table_a = Table() table_b = Table() mapper(TableA, table_a) mapper(TableB, table_b, inherits=TableA) table_b.get_parent() the reason I need it, is that I need to get information about the master table, because

[sqlalchemy] object has no attribute '_sa_session_id' error on session.clear()

2008-01-15 Thread maxi
Hi, I've an error when I try to execute a clear() method from session object. Traceback (most recent call last): File V:\nacer\bin\gui\planilla.py, line 280, in on_btn_apply_clicked self._savePlanilla() File V:\nacer\bin\gui\planilla.py, line 200, in _savePlanilla

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 4:33 AM, svilen wrote: also, i dont see a reason for it not to work if the (A jon B join C) is a polymunion - all the same, all columns will be present there, having None where missing. 0.4.3? unlikely, I dont see how it could work from a generic standpoint. the

[sqlalchemy] Re: Doing a dynamic Update

2008-01-15 Thread Rick Morrison
Hey Mike You don't need to go through that. Just populate the dictionary used for the execute() with the appropriate column name as the key, and you're good to go. On Jan 15, 2008 10:05 AM, Mike [EMAIL PROTECTED] wrote: Rick, On Jan 10, 7:02 pm, Rick Morrison [EMAIL PROTECTED] wrote: For

[sqlalchemy] Re: Is there a way to replace object in DB?

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 8:20 AM, Denis S. Otkidach wrote: On Jan 11, 2008 8:41 PM, Michael Bayer [EMAIL PROTECTED] wrote: what that looks like to me is that you're attempting to query the database for object ID #1 using merge(). when you merge(), its going to treat the object similarly to

[sqlalchemy] Re: object has no attribute '_sa_session_id' error on session.clear()

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 9:59 AM, maxi wrote: Hi, I've an error when I try to execute a clear() method from session object. Traceback (most recent call last): File V:\nacer\bin\gui\planilla.py, line 280, in on_btn_apply_clicked self._savePlanilla() File V:\nacer\bin\gui\planilla.py,

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread svilen
On Tuesday 15 January 2008 17:19:49 Michael Bayer wrote: On Jan 15, 2008, at 4:33 AM, svilen wrote: also, i dont see a reason for it not to work if the (A jon B join C) is a polymunion - all the same, all columns will be present there, having None where missing. 0.4.3? unlikely, I

[sqlalchemy] SelectResults and group_by

2008-01-15 Thread Glauco
Hi all for some reason i cannot work over the code before the result. The result was a SelectResults qry. Now i must do something like: MySelectResults.group_by( table.c.colname ).having( func.count( table.c.colname ) x ) Does anyone have any suggestion? Thank you Glauco --

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 10:49 AM, svilen wrote: hmmm, specify explicitly? e.g. query(A).eagerload( B.address) joined-inh via left-outer-join is enough, no need for polymunion. uh well i supposeeagerload options dont really affect the traversal that way and it would take some non-trivial

[sqlalchemy] Re: two scoped sessions in one app?

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 7:37 AM, Max Ischenko wrote: Hello, I need to access two databases from my app. I'm trying to use scoped_session helper: SessionA = scoped_session(sessionmaker(autoflush=True, transactional=False)) SessionB = scoped_session(sessionmaker(autoflush=True,

[sqlalchemy] Re: Doing a dynamic Update

2008-01-15 Thread Mike
On Jan 15, 9:20 am, Rick Morrison [EMAIL PROTECTED] wrote: Hey Mike You don't need to go through that. Just populate the dictionary used for the execute() with the appropriate column name as the key, and you're good to go. On Jan 15, 2008 10:05 AM, Mike [EMAIL PROTECTED] wrote:

[sqlalchemy] Re: Doing a dynamic Update

2008-01-15 Thread Rick Morrison
Two issues: a) You need to give SA a table definition for the table you're trying to update. b) You need to specify the name of the column to update in the dict(), not the string 'key' I've updated the script to work by passing in both the column name to update and the update value to use. I've

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread sdobrev
hmmm, specify explicitly? e.g. query(A).eagerload( B.address) joined-inh via left-outer-join is enough, no need for polymunion. i dont know how the current machinery for eagerload works, but imo knowing your level of lookahead-design, it should not be hard to apply that machinery over a

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread Michael Bayer
On Jan 15, 2008, at 5:17 PM, [EMAIL PROTECTED] wrote: hmmm, specify explicitly? e.g. query(A).eagerload( B.address) joined-inh via left-outer-join is enough, no need for polymunion. i dont know how the current machinery for eagerload works, but imo knowing your level of lookahead-design,

[sqlalchemy] Re: eagerloading polymorphic mapper

2008-01-15 Thread sdobrev
Michael Bayer wrote: On Jan 15, 2008, at 5:17 PM, [EMAIL PROTECTED] wrote: hmmm, specify explicitly? e.g. query(A).eagerload( B.address) joined-inh via left-outer-join is enough, no need for polymunion. i dont know how the current machinery for eagerload works, but imo knowing your