Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Chris Withers
On 04/10/2010 13:16, Mark Erbaugh wrote: If I were doing this in SQL, I would to the first command as SELECT count(*) FROM period WHERE period.cycle = ? Why would you do this first? Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Warwick Prince
Hi All Just my 2c; The original question was why is SA doing the select before it does the delete? and then the comment was added that he would have done a simple count instead.. It appears that he was not aware that the DELETE could return the count as well (indirectly) so in actual fact,

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Mark Erbaugh
On Oct 5, 2010, at 4:48 AM, Chris Withers wrote: On 04/10/2010 13:16, Mark Erbaugh wrote: If I were doing this in SQL, I would to the first command as SELECT count(*) FROM period WHERE period.cycle = ? Why would you do this first? I wasn't sure why SA was issuing a select realperiod

[sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True) cycle = Column(Integer) [more columns] I want to delete all records with a given value for the cycle column.

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 8:16 AM, Mark Erbaugh wrote: I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True) cycle = Column(Integer) [more columns] I want

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
On Oct 4, 2010, at 5:46 PM, Michael Bayer wrote: On Oct 4, 2010, at 8:16 AM, Mark Erbaugh wrote: I have a table described with: BASE = declarative_base(name=APP_ID) class Period(BASE): __tablename__ = 'period' realperiod = Column(Integer, primary_key=True)

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Michael Bayer
On Oct 4, 2010, at 8:06 PM, Mark Erbaugh wrote: Thanks. What is the purpose of SELECT period.realperiod AS period_realperiod FROM period WHERE period.cycle = ? that appears to be generated by the session.query ... call? the delete() and update() methods on Query want to invalidate

Re: [sqlalchemy] Batch Delete with ORM

2010-10-04 Thread Mark Erbaugh
On Oct 4, 2010, at 8:30 PM, Michael Bayer wrote: On Oct 4, 2010, at 8:06 PM, Mark Erbaugh wrote: Thanks. What is the purpose of SELECT period.realperiod AS period_realperiod FROM period WHERE period.cycle = ? that appears to be generated by the session.query ... call? the