[sqlalchemy] Re: Calculating percentage using subquery

2011-08-31 Thread nospam
,                 func.count(1).label('Amount'),                 ((100*func.count(1)) / subq.c.countall)).\                 group_by(FilmParticipation.PartType) -- Mike Conley On Mon, Aug 29, 2011 at 3:05 PM, nospam lhfied...@gmail.com wrote: I'm trying to construct a query in sqlalchemy similiar

[sqlalchemy] Re: Calculating percentage using subquery

2011-08-31 Thread nospam
)).group_by(ReportableCondition.disease) On Aug 31, 5:42 pm, nospam lhfied...@gmail.com wrote: I get an error saying the countall doesn't appear in the groupby, or its not an aggregating function. sqlalchemy.exc.ProgrammingError: (ProgrammingError) column anon_2.countall must appear in the GROUP

[sqlalchemy] Calculating percentage using subquery

2011-08-29 Thread nospam
I'm trying to construct a query in sqlalchemy similiar to this: SELECT FilmParticipation.PartType, COUNT(*) AS Amount, 100*COUNT(*) /(SELECT count(*) FROM FilmParticipation) AS Percentage_of_Total FROM FilmParticipation GROUP BY FilmParticipation.PartType; I create a subquery for the nested

[sqlalchemy] string concatentation of multiple columns in select statement

2011-08-12 Thread nospam
I'm trying to do something like this in sqlalchemy: select (score/10)*10 || '-' || (score/10)*10+9 as scorerange, count(*)from scoresgroup by score/10 order by 1 which should give: scorerange | count +--- 0-9|11 10-19 |14 20-29 | 3 30-39 | 2

[sqlalchemy] slow get query - somes taking 1.5 sec

2011-06-26 Thread nospam
I'm seeing a simple get taking a considerable amount of time. a = session.query(Annotation).get(annotation.id) This line can take anywhere between 0.15 secs to all the way up to 1.5 secs ... The query sqlalchemy produces is below. If I execute the query in pgadmin, it consistently runs in 47

[sqlalchemy] Re: slow get query - somes taking 1.5 sec

2011-06-26 Thread nospam
configuration. On Jun 26, 2011, at 10:25 AM, nospam wrote: I'm seeing a simple get taking a considerable amount of time. a = session.query(Annotation).get(annotation.id) This line can take anywhere between 0.15 secs to all the way up to 1.5 secs ...  The query sqlalchemy produces is below

[sqlalchemy] Re: help w/ creating complex query

2010-06-01 Thread nospam
order each user placed problem, but w/ more complexity around the last order definition. http://spyced.blogspot.com/2007/01/why-sqlalchemy-impresses-me.html Cheers, Lars On May 30, 12:06 pm, Lance Edgar lance.ed...@gmail.com wrote: On 5/30/2010 7:36 AM, nospam wrote: Thanks Lance.  Would

[sqlalchemy] Re: help w/ creating complex query

2010-05-30 Thread nospam
...@gmail.com wrote: On 5/29/2010 11:59 AM, nospam wrote: I'm trying to make the below logic into 1 query, so I don't have to run an individual query for each item; but can't figure out how to do it in sqlalchemy.  Any ideas what the code would look like? results = [] items = session.query(Item

[sqlalchemy] help w/ creating complex query

2010-05-29 Thread nospam
I'm trying to make the below logic into 1 query, so I don't have to run an individual query for each item; but can't figure out how to do it in sqlalchemy. Any ideas what the code would look like? results = [] items = session.query(Item).filter(Item.type == person) for item in items

[sqlalchemy] Error when changing two row values

2006-11-03 Thread Paul Nospam
I'm new to both python and SQLAlchemy, but am improving. I'm building a new application that will use a sqlite database. A unit test is failing with this exception: sqlalchemy.exceptions.ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1 Below is a small