Re: [sqlalchemy] The problem with the update

2013-06-18 Thread Michael Bayer
if the database you're using doesn't support UPDATE..FROM (which is likely), the normal way is to UPDATE with a subquery, which may be correlated or in a simple case like this just using IN: UPDATE price SET extra=2 WHERE price.id in (select price_id from person where name like 'J%')

Re: [sqlalchemy] The problem with the update

2013-06-18 Thread Michael Bayer
On Jun 18, 2013, at 4:46 PM, Witold Greń witold.g...@gmail.com wrote: But how resolved no 5? I try: subq = session.query(Person).filter(Person.gender == False, Person.name.like('M%')).subquery() y = session.query(Projects).filter(Projects.students.any(subq)).count() any() does the

[sqlalchemy] The problem with the update

2013-06-17 Thread Witold Greń
Hi, I'm Witold and learn Sqlalchemy :) I have a little problem, here it is: This is my DB: class Addressess(Base): __tablename__ = 'addressess' id = Column('id', Integer, Sequence('address_id_seq'), primary_key=True, index=True, unique=True, nullable=False) street =

[sqlalchemy] Having problem with constructing update ...from... with sqlalchemy

2011-09-12 Thread Geo
I have a tested update ... from.. statement, like so: update distributors set lead_bonus = lead_bonus + a.sum_amt from ( select target_member as id, sum(amount) as sum_amt from bonus_gen_history where bonus_type=2 and sub_type=1 and source_member in (select

Re: [sqlalchemy] Having problem with constructing update ...from... with sqlalchemy

2011-09-12 Thread Michael Bayer
On Sep 12, 2011, at 5:50 PM, Geo wrote: I have a tested update ... from.. statement, like so: UPDATE...FROM syntax, which is non-standard, isn't built into SQLAlchemy right now. You'd need to either convert this to use a correlated SELECT in the WHERE clause, stick to the SQL string, or

Re: [sqlalchemy] Having problem with constructing update ...from... with sqlalchemy

2011-09-12 Thread george hu
Thanks Michael, that solves my problem. On Mon, Sep 12, 2011 at 3:18 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Sep 12, 2011, at 5:50 PM, Geo wrote: I have a tested update ... from.. statement, like so: UPDATE...FROM syntax, which is non-standard, isn't built into SQLAlchemy