[sqlalchemy] Extracting metadata about results

2007-04-13 Thread bjpirt
Hi, I am using sqlalchemy with pylons and I am trying to extract some metadata about the set of relationships between the objects I have defined. Specifically, I am trying to work out how to tell what kind of objects are held in a one to many relationship. e.g. Two classes - person and phone

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
Ok, I'd rather handle it on the database level. Is that just a matter of creating a function and calling it on insert? Koen On Apr 13, 4:47 am, Ants Aasma [EMAIL PROTECTED] wrote: On Apr 13, 2:47 am, Jorge Godoy [EMAIL PROTECTED] wrote: IF you insist on doing that at your code, make the

[sqlalchemy] Re: query().filter_by(boolean)

2007-04-13 Thread Marco Mariani
Michael Bayer wrote: please file a ticket for this. done, #535 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Koen Bok
request_table = Table('request', metadata, Column('id', Integer, primary_key=True), Column('number', Integer, unique=True, nullable=True, default=text('(SELECT coalesce(max(number), 0) + 1 FROM request)'))) This seems to work well. But is this a good way to do

[sqlalchemy] Re: Child to parent - Uni-directional relationships - Is that supported ?

2007-04-13 Thread svilen
I have a Parent - Child (1:N) relationship between Class and Exam table. Class - Exam 1 :N Now since a Class could have millions of Exam I don't want have an attribute on Class called exams. Instead I only want an attribute on Exam to the parent Class. Can we do this in SA

[sqlalchemy] Re: Child to parent - Uni-directional relationships - Is that supported ?

2007-04-13 Thread Arun Kumar PG
cool thx. On 4/13/07, svilen [EMAIL PROTECTED] wrote: I have a Parent - Child (1:N) relationship between Class and Exam table. Class - Exam 1 :N Now since a Class could have millions of Exam I don't want have an attribute on Class called exams. Instead I only want

[sqlalchemy] Re: Column to default to itself

2007-04-13 Thread Ants Aasma
On Apr 13, 1:47 pm, Koen Bok [EMAIL PROTECTED] wrote: request_table = Table('request', metadata, Column('id', Integer, primary_key=True), Column('number', Integer, unique=True, nullable=True, default=text('(SELECT coalesce(max(number), 0) + 1 FROM

[sqlalchemy] Re: SELECT LIKE

2007-04-13 Thread King Simon-NFHD78
Disrupt07 wrote: I have a table storing users' info. table: userinfo columns: name, surname, age, location, ... I need to query this table using SQLAlchemy's ORM methods (e.g. select(), select_by(), get_by()). The query should be like SELECT * FROM userinfo WHERE name LIKE 'Ben%'

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Rick
Wouldn't the semantics of IN seem to imply that the expression foo IN empty set, should always evaluate to false? Clearly, foo is not in the empty set. I can't think of a use case where I'd use IN and want the expression anything IN empty set to evaluate to True. I'm another user who would use

[sqlalchemy] Re: SELECT LIKE

2007-04-13 Thread King Simon-NFHD78
Disrupt07 wrote @Simon Thanks. But what is your_query? Is it SQLAlchemy or pure SQL? It is a Query object, as described here: http://www.sqlalchemy.org/docs/datamapping.html If you haven't read them yet, I'd recommend working through a tutorial - I found this one really helpful:

[sqlalchemy] Re: Many to many optimization

2007-04-13 Thread Michael Bayer
On Apr 12, 2007, at 11:38 PM, Kaali wrote: I actually tried to use query.instances, but it behaved quite oddly. I didn't debug or even echo the SQL calls yet, but it made accessing those instances very slow. The actual instances call was quick, but when accessing the objects from the

[sqlalchemy] Re: threading.currentThread().session = create_session() ??

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 10:49 AM, Arun Kumar PG wrote: Hi All, I have a web application where I have multiple DAOs that may be called during phases within a request. Since I want to make sure that I get the same session with every DAO I was wondering if I can add a runtime session

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 11:40 AM, Rick wrote: Sorry, it looks like is already being discussed. (Serve me right for reading in threaded mode.) From my SA-newbie POV, I'd love it if col.in_() compiled down to false or 0 (whatever works). sure...but I was just saying, i get much more antsy if

[sqlalchemy] count and distinct

2007-04-13 Thread vkuznet
Hi, I found that if I do select([func.count(table.c.column)],distinct=True).execute() the resulting query is select distinct count(column) from table but it's not what I wanted. If my column has duplicates you got counting them, rather then count unique names. The proper SQL query would be

[sqlalchemy] Re: [PATCH] Filtered one_to_many relationships (Experimental)

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 12:51 PM, [EMAIL PROTECTED] wrote: haven't thought yet of where/how to hack this... i may have to abandon *-to-many-relations() alltogether, as i don't want/need them loaded - only filtered at view-time. or can i make some super- (or sub-) relation thing (propertyLoader?)

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Ants Aasma
On Apr 13, 6:40 pm, Rick [EMAIL PROTECTED] wrote: Sorry, it looks like is already being discussed. (Serve me right for reading in threaded mode.) From my SA-newbie POV, I'd love it if col.in_() compiled down to false or 0 (whatever works). col.in_() is easy to get working correctly, the

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 2:37 PM, Ants Aasma wrote: On Apr 13, 6:40 pm, Rick [EMAIL PROTECTED] wrote: Sorry, it looks like is already being discussed. (Serve me right for reading in threaded mode.) From my SA-newbie POV, I'd love it if col.in_() compiled down to false or 0 (whatever works).

[sqlalchemy] weird ORACLE behaviour with limit/offset

2007-04-13 Thread vkuznet
Hi, I added to my query the limit and offset (using ORACLE). To my surprise results ARE varying if I'll print my select or not before executing query. What I mean is the following sel = select () #print sel sel.execute() so, if I will not print my select, I'll get *smaller* number of

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Ants Aasma
On Apr 13, 10:16 pm, Michael Bayer [EMAIL PROTECTED] wrote: OK, first thing i wasnt sure about, is CASE supported on every DB that we support. I took a look at our CASE unit test and it appears it applies to all DBs...(although i cant verify it passes on firebird). Works on Firebird 1.5.3.

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread sdobrev
#476 - forget the visitor stuff; i use the simpler code that is in the text of 02/15/07 09:59:22 changed by svil comment, for some 2 months now, and all is ok. i've added the patch/code to that ticket as well as to #474/475. On Friday 13 April 2007 23:17:37 Ants Aasma wrote: On Apr 13, 10:16

[sqlalchemy] Re: IN() bug bit hard

2007-04-13 Thread Michael Bayer
On Apr 13, 2007, at 4:17 PM, Ants Aasma wrote: really, the work to do here is 5% the patch to the in_() method, and 95% making me a really nice unit test suite that will generatively test IN for every contingencyincluding the bind param stuff in #476 (but simpler code than whats patched