[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
Unfortunately, I posted the wrong version of my Itemtype class above; fortunately it wasn't important for what I was trying to show. Please replace class Itemtype with the following, and note the additional test lines and commentary which I also forgot to include. class Itemtype(object):

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
Well! I guess that's exactly why we post sometimes -- the process of producing the test case bumps the unconscious forward a few steps. I quit and did some pleasure reading for a while then came back. Here's my own answer that does exactly what I needed it to do. Add the following property on

[sqlalchemy] use func.* as adapter only

2008-11-25 Thread Glauco
I don't know if is better to use the psycopg adapter. Can i use the funct.* function only as adapter? example: In [1]: aa = [1,2,3,4,] In [2]: print sa.func.in_( *aa ) in(:in, :in_1, :in_2, :in_3) how to obtain this? in ( 1,2,3,4 ) thank you Glauco --

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
Arghh. Accidentally hitting 'Tab' in google groups takes you to the 'Send' button, then your next spacebar press prematurely sends your post. Ok, add the following property on Itemtype: @property def full_heritage(self): result = self.inherits[:] if result: for inherited in

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread az
Eric i'm not sure i follow all your mapping setup as it's too detail. but: i've been battling along similar data/feature inheritance+shading stuff along a branchy, recursive directed graph (not a pure tree as it has alternative short-cut paths in it), all over bitemporal objects and values

[sqlalchemy] ORM - Unmapping a class

2008-11-25 Thread Moshe C.
How would I unmap a class ( so that I can map it to another table from a parallel but distinct DB) ? I can't seem to find the documentation for the Mapper object itself. I may be going the wrong way about it. I want to map the same class to tables in different databases at different times.

[sqlalchemy] Re: use func.* as adapter only

2008-11-25 Thread Michael Bayer
Glauco wrote: I don't know if is better to use the psycopg adapter. Can i use the funct.* function only as adapter? example: In [1]: aa = [1,2,3,4,] In [2]: print sa.func.in_( *aa ) in(:in, :in_1, :in_2, :in_3) how to obtain this? in ( 1,2,3,4 ) perhaps you're looking for

[sqlalchemy] Re: ORM - Unmapping a class

2008-11-25 Thread Michael Bayer
Moshe C. wrote: How would I unmap a class ( so that I can map it to another table from a parallel but distinct DB) ? I can't seem to find the documentation for the Mapper object itself. I may be going the wrong way about it. I want to map the same class to tables in different databases at

[sqlalchemy] Re: Trouble with Strings getting converted to Unicode types

2008-11-25 Thread Harish Vishwanath
Hello, Thanks for your suggestion. I wanted to ask one more thing. I am using Sqlite with SQLA. Its a multi threaded application, but each thread gets its own session/engine. But, since it is Sqlite, isn't there just only one connection? Adding a Pool Listener, will make extra function calls

[sqlalchemy] Re: use func.* as adapter only

2008-11-25 Thread Glauco
Michael Bayer ha scritto: Glauco wrote: I don't know if is better to use the psycopg adapter. Can i use the funct.* function only as adapter? example: In [1]: aa = [1,2,3,4,] In [2]: print sa.func.in_( *aa ) in(:in, :in_1, :in_2, :in_3) how to obtain this? in ( 1,2,3,4 )

[sqlalchemy] Re: Trouble with Strings getting converted to Unicode types

2008-11-25 Thread Michael Bayer
Harish Vishwanath wrote: Hello, Thanks for your suggestion. I wanted to ask one more thing. I am using Sqlite with SQLA. Its a multi threaded application, but each thread gets its own session/engine. But, since it is Sqlite, isn't there just only one connection? sqlite very much wants

[sqlalchemy] Re: use func.* as adapter only

2008-11-25 Thread Michael Bayer
from sqlalchemy import * aa = [1,2,3,4] print func.in_(*[literal_column(str(x)) for x in aa]) in(1, 2, 3, 4) this is what you asked for ? Glauco wrote: Michael Bayer ha scritto: Glauco wrote: I don't know if is better to use the psycopg adapter. Can i use the funct.* function only

[sqlalchemy] Re: use func.* as adapter only

2008-11-25 Thread Glauco
Michael Bayer ha scritto: from sqlalchemy import * aa = [1,2,3,4] print func.in_(*[literal_column(str(x)) for x in aa]) in(1, 2, 3, 4) this is what you asked for ? Yess! well done ! I'm using the sa.func.literal_column instead of sa.literal_column... Thank you one more

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
What I don't like about my own solution, after all (see my 3rd post on this thread, after the accidental 2nd one prematurely submitted), is that it recursively traverses the Itemtype graph to make a list of itemtypes to constrain the scope of a request for the list of features upon which a given

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
Svil, Thanks for your reply. I have been following your posts with interest over the past half year (or I thought even longer). At first I thought you were crazy. But now I've found myself creating a model of similar complexity, as necessary to express the domain I'm working on. The purpose

[sqlalchemy] Re: ORM - Unmapping a class

2008-11-25 Thread Moshe C.
Thanks. I do not want to clear all maps, in order not to have to remap some classes that don't change. I think (3) answers my needs. I have an app. which has a mode which tells it with which of 2 DBs (with same schema) it is working . This mode is not changed often. If I understood this

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread az
Thanks for your reply. I have been following your posts with interest over the past half year (or I thought even longer). At first I thought you were crazy. But now I've found myself creating a model of similar complexity, as necessary to express the domain I'm working on. i think you're

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Ongerth
Yes, I am very glad to be free of multiversion and bitemporal concerns, although I will eventually be setting this up for partial multimaster asynchronous replication (but with a lot of intentional compromises in order to avoid the major, currently unsolved, problems with that entire field). As

[sqlalchemy] How to rebind a ScopedSession?

2008-11-25 Thread Moshe C.
The ScopedSession class has no bind_table method. Is there a way to get at a Session object from ScopedSession object? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send

[sqlalchemy] Re: How to rebind a ScopedSession?

2008-11-25 Thread Michael Bayer
sure just call it, session = ScopedSession() On Nov 25, 2008, at 6:41 PM, Moshe C. wrote: The ScopedSession class has no bind_table method. Is there a way to get at a Session object from ScopedSession object? --~--~-~--~~~---~--~~ You received this

[sqlalchemy] Re: Selecting from a self-referential mapper: recursive joins?

2008-11-25 Thread Eric Lemoine
Eric, a friendly comment: you do sound as crazy as Svil :-) Eric 2008/11/25, Eric Ongerth [EMAIL PROTECTED]: Yes, I am very glad to be free of multiversion and bitemporal concerns, although I will eventually be setting this up for partial multimaster asynchronous replication (but with a lot