[sqlalchemy] Re: Opinion on correct use of Sqlalchemy

2007-04-09 Thread Michael Bayer
On Apr 9, 2007, at 10:06 PM, Huy Do wrote: > > Michael Bayer wrote: >> Particularly for your query you are doing an eager load between >> "asset" and "location" yet a lot of your query criterion depends upon >> "location", so in that sense yes you have to use custom SQL, since >> query() will ne

[sqlalchemy] Re: Opinion on correct use of Sqlalchemy

2007-04-09 Thread Huy Do
Michael Bayer wrote: > On Apr 7, 2007, at 8:11 AM, HD Mail wrote: > > >> Hi, >> >> I was after some opinions on the following use of SA. >> >> 1. Is there any problems using SA in this way ? >> 2. Is there better ways of achieving this ? >> >> > ... > >> query = db.query(model.Asset

[sqlalchemy] Re: problems with threadlocal strategy and ResultProxy

2007-04-09 Thread Michael Bayer
id very much prefer a test case that isnt using Twisted since Ive no idea what twisted does with threads. it looks like the result proxy is being shared between threads (which i believe is an effect of the twisted reactor anyway?). if youre playing with threads to that degree the "threadlo

[sqlalchemy] Re: handing SELECT ... FOR UPDATE

2007-04-09 Thread Jonathan LaCour
Jonathan LaCour wrote: > What would be the best way to approach using `SELECT ... FOR UPDATE`? Answering my own question, it appears that there is a `lockmode` kwarg you can pass when creating a query that supports 'update' and 'update_nowait' as values: query = session.query(Queue, lockmo

[sqlalchemy] problems with threadlocal strategy and ResultProxy

2007-04-09 Thread Manlio Perillo
Hi. I have found some problems with threadlocal strategy and the ResultProxy. Here is the code that reproduces the problem, Twisted and PostgreSQL are required. I'm using SQLAlchemy 0.3.6-1 from Debian Etch. I don't know if this is a bug of SQLAlchemy. Is the ResultProxy thread safe? #! /us

[sqlalchemy] handing SELECT ... FOR UPDATE

2007-04-09 Thread Jonathan LaCour
So, at work, we have a particular use case where we need to be able to do a `SELECT ... FOR UPDATE` in order to lock some rows. In this particular project we will be using the ORM package and some advanced data mapping (including multiple table polymorphic inheritance). What would be the best wa

[sqlalchemy] Selecting objects with null foreign keys

2007-04-09 Thread Ryan
Suppose I have a table/object called Node that maps to Host by relation field 'host' on foreign key host_id that may be null. Why can't I do the following: Query(Node).select_by(host=None) When it seems obvious that I mean this: Query(Node).select_by(Node.c.host_id==None) I think the former w

[sqlalchemy] Re: Dealing with undefined/NULL foreign keys

2007-04-09 Thread Brendan Arnold
Thanks thats brilliant. Brendan On 4/9/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > On Apr 9, 2007, at 2:38 PM, Brendan Arnold wrote: > > > > > Hi there, > > > >> of course theres another view of this, which is why does your > >> application prefer a "blank" Address entry to None? the lat

[sqlalchemy] Re: Dealing with undefined/NULL foreign keys

2007-04-09 Thread Michael Bayer
On Apr 9, 2007, at 2:38 PM, Brendan Arnold wrote: > > Hi there, > >> of course theres another view of this, which is why does your >> application prefer a "blank" Address entry to None? the latter is >> more semantically correct. > > > > Name: > ${person.name} > City: > % if person.addre

[sqlalchemy] Re: Dealing with undefined/NULL foreign keys

2007-04-09 Thread Brendan Arnold
Hi there, > of course theres another view of this, which is why does your > application prefer a "blank" Address entry to None? the latter is > more semantically correct. I'm exporting the Person object to a web-template and I prefer the following, Name: ${person.name} City: ${person.

[sqlalchemy] Re: Dealing with undefined/NULL foreign keys

2007-04-09 Thread Michael Bayer
On Apr 9, 2007, at 11:25 AM, Brendan Arnold wrote: > Is there a way I can ensure that an empty instance of my Address > object is grafted onto the Person object even when corresponding data > is not found in the people table? you can either create a layer of abstraction between the actual map

[sqlalchemy] Re: Putting Session.flush in a seperate thread

2007-04-09 Thread Michael Bayer
On Apr 9, 2007, at 11:54 AM, David Anderson wrote: > > On 4/9/07, Michael Bayer <[EMAIL PROTECTED]> wrote: >>> I tried to build this already but I cannot figure out how to assign >>> the shared connection to a thread. I always get 'No connection >>> defined'. >> >> if youre on py2.4 check out th

[sqlalchemy] Re: Support for ordered lists of child items

2007-04-09 Thread Michael Bayer
we dont have the capability to automatically update ordering columns when the elements of a list are moved around. if you move the elements around, you need to execute some step that will update the index columns (or create a custom collection class that does this for you). On Apr 9, 200

[sqlalchemy] Support for ordered lists of child items

2007-04-09 Thread Aaron Digulla
Hello, I'm looking for a feature but couldn't find it in the docs. I have a tree like structure where the user can specify the order of the children of a node. In DB lingo, I have a parentId and an index column. When I load children, they should be ordered by the index. This seems to be supporte

[sqlalchemy] Re: Putting Session.flush in a seperate thread

2007-04-09 Thread David Anderson
On 4/9/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > I tried to build this already but I cannot figure out how to assign > > the shared connection to a thread. I always get 'No connection > > defined'. > > if youre on py2.4 check out threading.local(). Just to be clear here, as I'm also having

[sqlalchemy] Dealing with undefined/NULL foreign keys

2007-04-09 Thread Brendan Arnold
Hi there, I have a table of, say, people and another table of addresses. the people table refers to addresses through a foreign key. It is optional for each entry in the people table to have an address. When I construct an object using assign_mapper(session_context, Person, people_table, propert

[sqlalchemy] Re: Putting Session.flush in a seperate thread

2007-04-09 Thread Michael Bayer
On Apr 9, 2007, at 5:18 AM, Koen Bok wrote: > > We are building a GUI app, and we were thinking about wrapping > session.flush() in a thread with a timer that detects a timeout. That > way we would have better performace and we can generate warnings if > the connection goes down. Do you guys thi

[sqlalchemy] Re: Putting Session.flush in a seperate thread

2007-04-09 Thread Arun Kumar PG
may be a threadlocal strategy. On 4/9/07, Koen Bok <[EMAIL PROTECTED]> wrote: > > > We are building a GUI app, and we were thinking about wrapping > session.flush() in a thread with a timer that detects a timeout. That > way we would have better performace and we can generate warnings if > the con

[sqlalchemy] Re: Ordering by field in related object

2007-04-09 Thread Norjee
Thanks a lot!! Grin the Django query object actually allows for this sort of ordering so i just figured SqlAlchemy should allow it as well :/ But never mind now I know the trick it's super easy to adjust for it ;) --~--~-~--~~~---~--~~ You received this message b

[sqlalchemy] Putting Session.flush in a seperate thread

2007-04-09 Thread Koen Bok
We are building a GUI app, and we were thinking about wrapping session.flush() in a thread with a timer that detects a timeout. That way we would have better performace and we can generate warnings if the connection goes down. Do you guys think this is smart, or are there complications? I tried t