[sqlalchemy] how to prevent select() to generate a FROM statement ?

2008-03-28 Thread Julien
Hello, I have a rather complicated query on a medium sized database (millions of rows). One part of the query looks like the following : SELECT COUNT(sp.id), COUNT( (SELECT sp.id WHERE sp.site_id IN ( SELECT si.id FROM

[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 8:06 AM, Julien wrote: # Problem is here # func.count( select( [sp.c.id], sp.c.site_id.in_( select( [model.t_sites.c.id],

[sqlalchemy] Re: Use of new_instance() in the user-defined-state branch?

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 12:55 AM, Phillip J. Eby wrote: Sadly, about the only way for me to implement that without code duplication will be to temporarily change the item's __class__ to a subclass with an empty __init__ method. Unless there's a way to change the generated __init__ method to

[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?

2008-03-28 Thread Julien
It doesn't work because more than one row are returned by the subquery used in the expression ... On Fri, 2008-03-28 at 09:30 -0400, Michael Bayer wrote: On Mar 28, 2008, at 8:06 AM, Julien wrote: # Problem is here # func.count( select(

[sqlalchemy] Re: Multiple Levels of Inheritance

2008-03-28 Thread Chris Guin
Thanks! That appears to have done it. Chris Guin At 05:28 PM 3/27/2008, you wrote: On Mar 27, 2008, at 3:54 PM, Chris Guin wrote: Does anyone know where I could find a working example of multiple levels of inheritance using joined table inheritance? Right now I have the following

[sqlalchemy] Re: Attribute error

2008-03-28 Thread pyplexed
That's fixed it. Thanks very much. On Mar 26, 7:03 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 26, 2008, at 1:34 PM, pyplexed wrote: Hi all, I'm a complete newcomer to SA, and I've tried to adapt an example I found on-line to look a bit more like the problem I'm trying to

[sqlalchemy] Re: Use of new_instance() in the user-defined-state branch?

2008-03-28 Thread Phillip J. Eby
At 09:45 AM 3/28/2008 -0400, Michael Bayer wrote: On Mar 28, 2008, at 12:55 AM, Phillip J. Eby wrote: Sadly, about the only way for me to implement that without code duplication will be to temporarily change the item's __class__ to a subclass with an empty __init__ method. Unless there's a

[sqlalchemy] query on stdout

2008-03-28 Thread vkuznet
Hi, I just noticed that both 0.3.x and 0.4.x versions of SQLAlchemy print compiled query for MySQL without binded parameters, so typical printout for MySQL looks like SELECT DISTINCT block.`Path` AS `block_Path` FROM tier0.block WHERE block.`Path` LIKE %s while doing the same with ORACLE

[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?

2008-03-28 Thread Julien
In the documentation I found Note that from objects are automatically located within the columns and whereclause ClauseElements for the select() statement. It is precisely the thing I do not want to.. no way to disable it .. ? Thanks, Julien On Fri, 2008-03-28 at 09:30 -0400, Michael Bayer

[sqlalchemy] Re: how to prevent select() to generate a FROM statement ?

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 1:36 PM, Julien wrote: in fact all the problem is that I can't generate the following query: SELECT xx.yy, (SELECT xx.yy WHERE cond) FROM foobar xx; where xx.yy are the same columns SQLAlchemy generates : SELECT xx.yy, (SELECT xx.yy FROM foobar xx WHERE cond) FROM

[sqlalchemy] Re: Use of new_instance() in the user-defined-state branch?

2008-03-28 Thread Phillip J. Eby
So you're still disagreeing with Jason, who's quite explicitly saying that SA's __init__ will blow up if it gets called. Which of you is right? :) At 11:38 AM 3/28/2008 -0400, Michael Bayer wrote: On Mar 28, 2008, at 10:58 AM, Phillip J. Eby wrote: Sorry, I should have included more

[sqlalchemy] Re: Use of new_instance() in the user-defined-state branch?

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 12:13 PM, Phillip J. Eby wrote: So you're still disagreeing with Jason, who's quite explicitly saying that SA's __init__ will blow up if it gets called. Which of you is right? :) SA's __init__ does not blow up if it gets called. It just checks that mappers are

[sqlalchemy] Re: Use of new_instance() in the user-defined-state branch?

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 12:28 PM, Michael Bayer wrote: On Mar 28, 2008, at 12:13 PM, Phillip J. Eby wrote: So you're still disagreeing with Jason, who's quite explicitly saying that SA's __init__ will blow up if it gets called. Which of you is right? :) SA's __init__ does not blow up if

[sqlalchemy] Elixir 0.5.2 released!

2008-03-28 Thread Gaetan de Menten
I am very pleased to announce that version 0.5.2 of Elixir (http://elixir.ematia.de) is now available. As always, feedback is very welcome, preferably on Elixir mailing list. This is a minor bug fixes release (mostly restoring python 2.3 compatibility). The full list of changes can be seen at:

[sqlalchemy] Strange caching problem with Apache

2008-03-28 Thread john spurling
I'm having a strange caching problem when using SQLAlchemy with Apache and mod_python. Using the ORM, I have a class that maps to a simple table with two columns and no foreign keys. When I get an HTTP request, I get the desired object by primary key and return the value of the attribute that

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 6:42 PM, john spurling wrote: The funny part is that if I run this very same code in a standalone Python process (where the process is kept alive, like the Apache process), there is no caching behavior; the correct value is returned every single time. If it's run in

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-28 Thread john spurling
On Mar 28, 4:12 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 6:42 PM, john spurling wrote: The funny part is that if I run this very same code in a standalone Python process (where the process is kept alive, like the Apache process), there is no caching behavior; the

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it. Unfortunately, the caching behavior persists. Any other

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-28 Thread Graham Dumpleton
On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is 0. I also called session.clear() before using it.

[sqlalchemy] Re: Strange caching problem with Apache

2008-03-28 Thread Michael Bayer
On Mar 28, 2008, at 11:54 PM, Graham Dumpleton wrote: On Mar 29, 11:02 am, Michael Bayer [EMAIL PROTECTED] wrote: On Mar 28, 2008, at 7:56 PM, john spurling wrote: I added debugging to get id(session) and len(list(session)). The session id is unique every time, and len(list(session)) is