[sqlalchemy] Help on Counting Please

2013-10-23 Thread Warwick Prince
Hi All Please excuse this relatively noob question, but I can not for the life of me find the answer in docs. (Probably because I don't know what I'm looking for). I have a table with two columns A and B. A can have many duplicate values. e.g. A B 1 a 1 b 1 c 1

Re: [sqlalchemy] Help on Counting Please

2013-10-23 Thread anh le
Hi, Have you tried: select A, count(*) from the_table group by A On Wed, Oct 23, 2013 at 4:17 PM, Warwick Prince warwi...@mushroomsys.com wrote: Hi All Please excuse this relatively noob question, but I can not for the life of me find the answer in docs. (Probably because I don't know what

Re: [sqlalchemy] Help on Counting Please

2013-10-23 Thread Warwick Prince
Hi Anh Thanks for clearing my head. I had devised considerably more complex attempts! So, the answer is; table.select().group_by(table.c.A).with_only_columns([table.c.A, func.count(1).label('count')]).execute().fetchall() :-) n 23/10/2013, at 7:29 PM, anh le anh...@gmail.com wrote: Hi,

[sqlalchemy] is ForeignKey() the only ORM feature (outside of table setup) that requires table knowledge

2013-10-23 Thread Jonathan Vanasco
this has just confused me for a while , and constantly trips me up... class FirstTable() __tablename__ = 'first_table' id = Column(Integer, primary_key=True) class SecondTable() __tablename__ = 'second_table' id = Column(sa.Integer, primary_key=True)

[sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-23 Thread Daniel Grace
I have a situation where an object in the ORM performs some calculations and other assorted checks. One of these situations is checking to see the difference between the original value of an attribute and the current value -- in particular, some of the validation going on should prohibit a

Re: [sqlalchemy] Getting the unmodified version of an object without losing changes

2013-10-23 Thread Michael Bayer
On Oct 23, 2013, at 8:06 PM, Daniel Grace thisgenericn...@gmail.com wrote: I have a situation where an object in the ORM performs some calculations and other assorted checks. One of these situations is checking to see the difference between the original value of an attribute and the