[sqlalchemy] Re: Select as

2009-11-17 Thread Tomas Zulberti
On Nov 16, 5:15 pm, Conor conor.edward.da...@gmail.com wrote: Tomas Zulberti wrote: Hi. I am sort of a newbie on SQLAlchemy. Is there a way to do a query with the ORM, and doing an as on the select. For example: class Example(Base):     name = Column(Unicode(512) ) query =

[sqlalchemy] Re: column label and order by

2009-11-17 Thread rajasekhar911
anyone?? On Nov 14, 6:48 pm, rajasekhar911 rajasekhar...@gmail.com wrote: Hi guys, how do i apply order by on a column with a label. My requirement is like this class x   id,   amount,   date i have to group based on id and take sum of amount within a date range. i am applying a

[sqlalchemy] Re: column label and order by

2009-11-17 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of rajasekhar911 Sent: 17 November 2009 11:32 To: sqlalchemy Subject: [sqlalchemy] Re: column label and order by anyone?? On Nov 14, 6:48 pm, rajasekhar911

[sqlalchemy] Re: column label and order by

2009-11-17 Thread Mike Conley
And you do need to quote the column name in order_by also. session.query(func.sum(X.amount).label('tot_amount')).group_by(X.date).order_by('tot_amount').limit(10) generates code SELECT sum(x.amount) AS tot_amount FROM x GROUP BY x.date ORDER BY tot_amount LIMIT 10 OFFSET 0

[sqlalchemy] Re: UnboundExecutionError with object on session

2009-11-17 Thread Fernando Takai
I have changed my code to be like this: job = session.merge(job) # Merge docs says that object does not get into the session session.add(job) log.info(Job finished! %s % job.file) When using latest SQLAlchemy trunk and 0.5.6 sometimes i get UnboundExecutionError. Also, i can assure that all

[sqlalchemy] Re: column label and order by

2009-11-17 Thread rajasekhar911
session.query( func.sum(x.amount).label('tot_amount'), x.id ). filter(x.datefromdate).filter(x.datetodate). .group_by(x.id) .order_by('tot_amount DESC') .limit(5) On Nov 17, 4:55 pm, Mike Conley mconl...@gmail.com wrote: And you do need to quote the column name in order_by also.

[sqlalchemy] Re: filtering with an association_proxy

2009-11-17 Thread Michael Bayer
scott wrote: Is there a way to filter a query involving an association_proxy? For example, say I have a one to many relation between Pages and Tags, and an association_proxy like this to let me represent tags as a list of strings. tag_objects = orm.relation('Tag') tags =

[sqlalchemy] Cascading rules

2009-11-17 Thread kwarg
I have a one-to-many object relation, A-to-B. When an instance of A with several Bs is created it needs to be persisted by SQLAlchemy. I have that via save-update rule. But when I delete an A I DON'T WANT SQLAlchemy to do anything to its Bs - it's taken care of by foreign key constraints in the

[sqlalchemy] Re: Identical column names in parent and child classes with joined-table inheritance

2009-11-17 Thread bojanb
This does it. One small drawback is that since the field is now defined as an attribute, one can't query on it (ie. session.query (class_).filter_by(modified_by='jack')), but we don't envison such a use case for this funcionality so it's OK for us. Recap of what was done: table columns were

[sqlalchemy] Re: Identical column names in parent and child classes with joined-table inheritance

2009-11-17 Thread Michael Bayer
bojanb wrote: This does it. One small drawback is that since the field is now defined as an attribute, one can't query on it (ie. session.query (class_).filter_by(modified_by='jack')), but we don't envison such a use case for this funcionality so it's OK for us. you get this by using

[sqlalchemy] Moving (new) objects between sessions and committing?

2009-11-17 Thread psychogenic
Greetings SA community! I've got mapped objects being created and added to a session, but not committed. Once in a while, I'd like to do something a-la: oid = 42 object = MyClass(oid) sessionA.add(object) # ... time passes, things happen ... then object = get_obj_from_session(oid,

[sqlalchemy] Re: Moving (new) objects between sessions and committing?

2009-11-17 Thread Michael Bayer
psychogenic wrote: My questions are: - why does the instance state think it doesn't need to insert this object, that was never committed? it was INSERTed in your other session. You probably didn't commit the transaction. The object then gets the key and such is now persistent, until

[sqlalchemy] Re: Writing a new database dialect

2009-11-17 Thread Eric Smith
Eric Smith wrote: I'm writing a new database dialect for sqlalchemy 0.6 for Netezza. This is on Windows. I have an ODBC driver for Netezza. A couple of questions: - Why isn't there a generic talk to an ODBC source dialect? I thought that was the beauty of ODBC. Is this possible and

[sqlalchemy] model root object in container hierarchy

2009-11-17 Thread fogathm...@googlemail.com
Hello! I want to introduce an artificial root object into my model to obtain a traversable container hierarchy: class Root: foos = [] bars = [] Foo and Bar are both mapped classes and I had hoped to be able to do something like mapper(Root, properties=dict(foos=relation(Foo),