[sqlalchemy] Re: new questions

2009-08-19 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of darkblueB Sent: 19 August 2009 02:58 To: sqlalchemy Subject: [sqlalchemy] Re: new questions Hi Simon thanks for the reply.. Your second part is straightforward.. The first

[sqlalchemy] Deleting multiple objects

2009-08-19 Thread thatsanicehatyouhave
Hello, I have several objects from a relation that I'd like to delete. To me, this would be a natural syntax: session.delete(office.users) to delete all of the user objects. I get this error when doing this: raise exc.UnmappedInstanceError(instance)

[sqlalchemy] Re: Deleting multiple objects

2009-08-19 Thread Mike Conley
The delete method of query supports bulk deletes. In your case it might be something like session.query(Users).filter(User.officeid==office.id).delete() Any query can be used; there are probably more elegant ways to take advantage of the relation 'users' also. Make sure you read the

[sqlalchemy] Re: How can I built two different ForeignKey relation refer to a same model.

2009-08-19 Thread Alisue
OOps. Doesn't matter. It's all my fault. I used Unittest and I delete management_company on tearDown. (duaring management_company_id set nullable=False) I set 'cascade=all' and everything goes Correct. Sorry. On 8月20日, 午前11:41, Alisue hello.goodbye.by.beat...@gmail.com wrote: Article has two

[sqlalchemy] How can I built two different ForeignKey relation refer to a same model.

2009-08-19 Thread Alisue
Article has two company. 'management_company' and 'intermediate_company' So I wrote code like below. code class Company(Base): __tablename__ = 'companies' id = Column(Integer, primary_key=True) name = Column(String(255)) class Article(Base): __tablename__ = 'articles' id =