[sqlalchemy] Deletion of a row from an association table

2020-08-11 Thread William Phillips
I am working on an app using python3 and SqlAlchemy for SQLite3 database management. I have some tables that have a Many to Many relationship. I've created an association table to handle this relationship. Class Machine(Base): __tablename__ 'machine' machine_ID = Column(Integer,

Re: [sqlalchemy] Deletion of object with relationship(lazy='raise')

2019-11-22 Thread Mike Bayer
I can confirm this is a bug as I've found precedent for this not having to raise, new issue is https://github.com/sqlalchemy/sqlalchemy/issues/4997 On Fri, Nov 22, 2019, at 9:24 AM, Mike Bayer wrote: > that said, I'm looking at this as a potential bug because it should be able > to leave this

Re: [sqlalchemy] Deletion of object with relationship(lazy='raise')

2019-11-22 Thread Mike Bayer
that said, I'm looking at this as a potential bug because it should be able to leave this attribute alone, not really sure how this should be handled. On Fri, Nov 22, 2019, at 9:21 AM, Mike Bayer wrote: > lazy="raise" on a many to one is problematic because a lot of many-to-one > operations

Re: [sqlalchemy] Deletion of object with relationship(lazy='raise')

2019-11-22 Thread Mike Bayer
lazy="raise" on a many to one is problematic because a lot of many-to-one operations involve pulling up the object from the identity map, and that's it. since people are usually only trying to guard against SQL being emitted, use the raise_on_sql option instead: parent = relationship(Parent,

[sqlalchemy] Deletion of object with relationship(lazy='raise')

2019-11-22 Thread Marat Sharafutdinov
from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, sessionmaker Base = declarative_base() class Parent(Base): __tablename__ = 'parents' id = Column(Integer, primary_key=True)

[sqlalchemy] Deletion

2011-10-18 Thread fribes
Hi all, Despite some doc and web digging, I didn't find how to tell sqa to behave the way I want : on deletion on Peripheral, also delete in Actuator. with the following code, the record in Actuator remains after a deletion, and a subsequent creation fails with IntegrityError. class

Re: [sqlalchemy] Deletion

2011-10-18 Thread Mike Conley
How are you doing the delete? This should delete both. a = sess.query(Peripheral).filter(Peripheral.label=='some label').one() sess.delete(a) sess.commit() This will not work. a = sess.query(Peripheral).filter(Peripheral.label=='some label').delete() I think the explanation

Re: [sqlalchemy] Deletion

2011-10-18 Thread Michael Bayer
On Oct 18, 2011, at 10:03 AM, fribes wrote: Hi all, Despite some doc and web digging, I didn't find how to tell sqa to behave the way I want : on deletion on Peripheral, also delete in Actuator. with the following code, the record in Actuator remains after a deletion, and a

Re: [sqlalchemy] Deletion order during flush is not correct.

2010-12-15 Thread Michael Bayer
This is an interesting edge case and I can probably ensure that the dependency between Parent/Child is present in the unit of work even if there is no known linkage at the Child.parent level for the objects actually present - ticket #2002 is added for this. In the meantime, the uow needs to be

Re: [sqlalchemy] Deletion order during flush is not correct.

2010-12-15 Thread Will Weaver
Wow, this has been a problem for me for the past 3 or 4 days and took a while to get to that example. Defining the backrefs or the relationships in the opposite direction did the job. I had intentionally left out some of the backreffed relationships because I didn't need them for what I was

Re: [sqlalchemy] Deletion order during flush is not correct.

2010-12-15 Thread Michael Bayer
It was in fact a one liner, so you can go back to your original code if you use the latest 0.6 tip: http://hg.sqlalchemy.org/sqlalchemy/archive/rel_0_6.tar.gz thanks for the bug report ! On Dec 15, 2010, at 3:41 PM, Will Weaver wrote: Wow, this has been a problem for me for the past 3 or 4

[sqlalchemy] Deletion of referenced objects fails

2007-10-30 Thread Felix Schwarz
Hi, I have a problem using SQLAlchemy 0.4 when deleting referenced objects in a PostgreSQL database and adding new ones within the same transaction. Originally, I found the problem with Elixir 0.4.0-pre (svn r216) and SQLAlchemy 0.3.11 -

[sqlalchemy] deletion behavior question

2007-02-12 Thread iain duncan
I would like some objects that are related through many to many tables to delete the many to many entry on deletion, but NOT the endpoint. It seems that cascade=all deletes both, and no arg to cascade leaves left over invalid entries in the manytomany table. Is there a suggested way to deal with