Re: [sqlalchemy] Entity KeyErrors under heavy load

2011-08-29 Thread Michael Bayer
OK well there's a short answer and a longer answer here. The short answer is that this is only a warning, not an "error" per se as it occurs during garbage collection, and is entirely harmless. To totally prevent them, probably ensuring that close() is called on all Session objects before rem

[sqlalchemy] Entity KeyErrors under heavy load

2011-08-29 Thread Paul Andrew
Hi there, We're running load tests against our Pylons application, which uses SQLAlchemy to hit an Oracle DB. Under load, we're starting to see errors pop up in our Apache logs: [Mon Aug 29 13:39:59 2011] [error] Exception KeyError: KeyError((, (631,)),) in > ignored [Mon Aug 29 13:39:59 2011] [

Re: [sqlalchemy] Calculating percentage using subquery

2011-08-29 Thread Mike Conley
This should work subq = sess.query(func.count('*').label('countall')).\ select_from(FilmParticipation).subquery() qry = sess.query(FilmParticipation.PartType, func.count(1).label('Amount'), ((100*func.count(1)) / subq.c.countall)).\

[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 sel

Re: [sqlalchemy] Using super from declared_attr

2011-08-29 Thread Michael Bayer
The declared_attr attributes are called by the metaclass for IceCream before the creation of the IceCream class is complete, and therefore available in the module namespace, so you need to rely on cls to get at the appropriate contextbut if you want Edible, you're probably best saying that

[sqlalchemy] Using super from declared_attr

2011-08-29 Thread Fayaz Yusuf Khan
Hi, I'm trying to call the base class attributes from a declared_attr definition. Something like: class Edible(Base): __tablename__ = 'edible' brand = Column(String(20), primary_key=True) edible_type = Column(String(20), primary_key=True) __mapper_args__ = {'polymorphic_on': edib