[sqlalchemy] Re: Calling a function (Stored Procedure) returning a recordset

2007-05-02 Thread Sanjay
tasklist = func.get_tasklist(engine=engine).execute() # is this the correct way? looks fine to me. for the rest of it, im not very familiar with PG stored procedures. I think SQLAlchemy code is translating to SELECT get_tasklist(). But what is actually needed is SELECT * FROM

[sqlalchemy] Ticket 185-like issues on inheriting from alias in 0.3.7

2007-05-02 Thread Graham Stratton
Hi, Now I've set the maximum identifier length to 30 chars (thanks!), I have a new problem. My Person class inherits from PersonEntry, and the get() method on Person now fails when passed a single id. This seems to be due to the removal of the workaround for #185 in orm.query.Query._get I

[sqlalchemy] Re: select() vs. self.session.query(): no group_by, different params?

2007-05-02 Thread Glauco
Michael Bayer ha scritto: On Apr 24, 2007, at 4:05 PM, Chris Shenton wrote: Am I being stupid about not seeing the difference -- what keywords and arguments I can use -- between: self.session.query(MyClass).select(...) and select(...) these two methods are fundamentally

[sqlalchemy] Re: Calling a function (Stored Procedure) returning a recordset

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 2:25 AM, Sanjay wrote: tasklist = func.get_tasklist(engine=engine).execute() # is this the correct way? looks fine to me. for the rest of it, im not very familiar with PG stored procedures. I think SQLAlchemy code is translating to SELECT get_tasklist(). But

[sqlalchemy] Re: Calling a function (Stored Procedure) returning a recordset

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 10:00 AM, Sanjay wrote: So, probably the question is, What SQLAlchemy code will translate to SELECT * FROM get_tasklist(). Needing suggestions. Is it like this?: tasklist = engine.text('SELECT * FROM get_tasklist()').execute().fetchall() It returns a list. Any

[sqlalchemy] Re: select() vs. self.session.query(): no group_by, different params?

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 11:23 AM, Glauco wrote: Example: create table people ( name text, surname text, type CASE 'A','B','C' ) There is no solution to do for example the simple query based over the mapper People: select count(type) from people group by type; first of all, i dont

[sqlalchemy] Adding few deferred properties from select()

2007-05-02 Thread askel
Hello everyone! I'm trying to implement deferred property loading using select(): summaries = select( [ func.max(transactions.c.processed_at).label('last_used'), func.count(transactions.c.id).label('times_used'), ], from_obj=[transactions], ).alias('summaries') account_mapper =

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 2:12 PM, askel wrote: Hello everyone! I'm trying to implement deferred property loading using select(): summaries = select( [ func.max(transactions.c.processed_at).label('last_used'), func.count(transactions.c.id).label('times_used'), ],

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
Michael, Thank you for answering. The following is what I tried in order to follow your advise: account_summaries = select( [ transactions.c.account_id, func.max(transactions.c.processed_at).label('last_used'), func.count(transactions.c.id).label('times_used'), ],

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 3:53 PM, askel wrote: Michael, Thank you for answering. The following is what I tried in order to follow your advise: account_summaries = select( [ transactions.c.account_id, func.max(transactions.c.processed_at).label('last_used'),

[sqlalchemy] ANN: collective.lead - a minimalist SQLAlchemy/Zope 2 integration library

2007-05-02 Thread Martin Aspeli
Hi all, I've just released Lead (pun intended), aka collective.lead, a minimalist Zope 2/SQLAlchemy integration package. http://cheeseshop.python.org/pypi/collective.lead There are at least two other Zope2/SA integration packages that I know of - z3c.sqlalchemy and ore.alchemist. Both of

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
Michael, transaction.account_id is not a primary key of transactions table. I added fields I use for grouping to primary_key. Then I had to add foreign_key argument to 'summary' relation() call. And finally it all worked as expected. However, I noticed that it doesn't actually matter which

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread Michael Bayer
On May 2, 2007, at 7:56 PM, askel wrote: Michael, transaction.account_id is not a primary key of transactions table. I added fields I use for grouping to primary_key. Then I had to add foreign_key argument to 'summary' relation() call. And finally it all worked as expected. However, I

[sqlalchemy] Queries on computed properties

2007-05-02 Thread Kirk Strauser
I'm new to SQLAlchemy and not sure exactly how to explain this in its terminology, so please bear with me. We moving to replace an in-house developed ORM with SQLAlchemy because it works better with the software we want to use. One problem I have is that we're working with some unnormalized

[sqlalchemy] Re: Queries on computed properties

2007-05-02 Thread Michael Bayer
On May 2, 1:54 pm, Kirk Strauser [EMAIL PROTECTED] wrote: I'm new to SQLAlchemy and not sure exactly how to explain this in its terminology, so please bear with me. We moving to replace an in-house developed ORM with SQLAlchemy because it works better with the software we want to use. One

[sqlalchemy] Re: Queries on computed properties

2007-05-02 Thread Michael Bayer
oh duh, i forgot about the new thing Gaetan came up with, try this too: mapper(Invoice, invoice_table, properties={ 'customer':column_property(func.substr(invoice_table.c.invnum, 1, 4).label('customer')) }) --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: Adding few deferred properties from select()

2007-05-02 Thread askel
On May 2, 8:28 pm, Michael Bayer [EMAIL PROTECTED] wrote: take a look at your SQL output with echo and make sure the queries make sense. that it works with arbitrary columns as pk/fk could just be due to particular data youre working with, but you definitely want to pick a proper candidate