[sqlalchemy] Re: Deletion

2011-10-19 Thread Fabien Ribes
You're right ! Thanks On Oct 18, 7:32 pm, Mike Conley mconl...@gmail.com wrote: 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 =

[sqlalchemy] Re: Deletion

2011-10-19 Thread Fabien Ribes
On Oct 18, 8:01 pm, Michael Bayer mike...@zzzcomputing.com wrote: 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

[sqlalchemy] sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-19 Thread lestat
I have such model: class Test(db.Model): __tablename__ = 'test' id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(512), nullable=False) level = None Some code generate RAW SQL with additional dynamic data. For example it like:

Re: [sqlalchemy] Re: Deletion

2011-10-19 Thread Michael Bayer
On Oct 19, 2011, at 3:55 AM, Fabien Ribes wrote: usually relationship() with cascade=all, delete-orphan is used for this use case, so that SQLAlchemy can maintain knowledge about the link between Peripheral and Actuator. The other alternative is to use ON DELETE CASCADE on the foreign

Re: [sqlalchemy] sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-19 Thread Michael Bayer
On Oct 19, 2011, at 8:19 AM, lestat wrote: I have such model: class Test(db.Model): __tablename__ = 'test' id = db.Column(db.Integer, primary_key=True) subject = db.Column(db.String(512), nullable=False) level = None arbitrary SQL expressions can be added to a mapping

[sqlalchemy] Re: sqlalchemy from_statement dynamic attributes for python objects instances

2011-10-19 Thread lestat
No, it not just 99. It generated by difficult RAW SQL with hierarchy library https://github.com/marplatense/sqla_hierarchy and with recursive SQL. FULL SQL is like http://pastebin.com/b0wGUegy It adds additional data as level, connect_path, is_leaf. I get this SQL from hierarchy library and

[sqlalchemy] Re: How to keep ORM Sessions in sync when using the SQL expression language as well?

2011-10-19 Thread Russ
Another wrinkle to this is that if I already have relationship data within the ORM, but then add records outside of the ORM with the expression language, I can't figure out how to reconcile this efficiently. As a specific example, if I add the snippet below to my original example, you can see

Re: [sqlalchemy] How to keep ORM Sessions in sync when using the SQL expression language as well?

2011-10-19 Thread Michael Bayer
On Oct 18, 2011, at 3:40 PM, Russ wrote: I often mix up the SQL expression language with the use of an ORM session, and it is great that SQLAlchemy more than supports this. But... what are the recommended ways to keep the session in sync with what you do with the SQL expression stuff?

Re: [sqlalchemy] How to keep ORM Sessions in sync when using the SQL expression language as well?

2011-10-19 Thread Russ
Thanks very much for the response... lots to chew on here. well pretty much being saavy about expiration is the primary approach. The rows you affect via an execute(), if they've been loaded in the session they'd need to be expired from memory. I understand this somewhat and had done