[sqlalchemy] Re: Cascade Delete, session confusion

2014-03-09 Thread Dmitry Berman
I also looked at this through SQLite database browser, and the database is correct, so is this a Python side error? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and stop receiving emails from it, send an email to

[sqlalchemy] Re: Cascade Deletes

2011-08-09 Thread Stefano Fontanelli
Il 09/08/11 02.42, Aviv Giladi ha scritto: Dear Stefano, First of all, thank you. Allow me to express how much I appreciate your time and assistance - you and your colleagues are making the technology world this much better by being so attentive and helpful! Thank you. Therefore I chose

[sqlalchemy] Re: Cascade Deletes

2011-08-08 Thread Aviv Giladi
Stefano, Thank you again for your time. I am sorry for not posting my actual code - it is sensitive, therefore I am trying to reproduce the same issue with different code. In my __init__ function of my Rating I am setting 3 members that are objects like so: self.member = member These members

[sqlalchemy] Re: Cascade Deletes

2011-08-08 Thread Stefano Fontanelli
Il 08/08/11 22.53, Aviv Giladi ha scritto: Dear Stefano, I have been able to create a reproducing project. I am sending it to you directly because I was unable to figure out how to attach the test file to the message board. I will post our findings there once we are done. The included

Re: [sqlalchemy] Re: Cascade Deletes

2011-08-07 Thread Stefano Fontanelli
Il 07/08/11 00.35, Aviv Giladi ha scritto: Everything works great when I create and assign all 3 subratings to the rating object before I add it to the session. However, I need to be able to create a Rating that only has 1 or 2 subratings, and the other subratings absent. When I do that,

[sqlalchemy] Re: Cascade Deletes

2011-08-07 Thread Aviv Giladi
I see. Where can I start looking for such an error? What could possibly be causing this? On Aug 7, 6:51 am, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 07/08/11 00.35, Aviv Giladi ha scritto: Everything works great when I create and assign all 3 subratings to the rating object

Re: [sqlalchemy] Re: Cascade Deletes

2011-08-07 Thread Stefano Fontanelli
Il 07/08/11 20.08, Aviv Giladi ha scritto: I see. Where can I start looking for such an error? What could possibly be causing this? I'm sorry but I cannot help you without your code... not a similar code but THE code which produce that error. Regards, Stefano. -- Ing. Stefano

Re: [sqlalchemy] Re: Cascade Deletes

2011-08-06 Thread Stefano Fontanelli
Il 06/08/11 00.32, Aviv Giladi ha scritto: Hi Stefano, I create and add a Rating and Subrating (both end up in the DB no problem). Then, I call session.delete(rating_obj) and commit it. I look at the DB, and the Rating is gone, but the SubRating is still there. The DB shows that the Rating has

[sqlalchemy] Re: Cascade Deletes

2011-08-06 Thread Aviv Giladi
Stefano, Thanks! Your script helped me narrow down the problem. My Rating object has multiple Subrating objects. So in my real code, I have something like: class SubRating1(Base): __tablename__ = 'subratings1' id = Column(Integer, primary_key=True) name = Column(Unicode(32),

Re: [sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Stefano Fontanelli
Il 04/08/11 21.27, Aviv Giladi ha scritto: Hey, Tried adding cascade to Rating's backref call like so: subrating = relationship(SubRating, backref=backref(rating, cascade=all, delete-orphan uselist=False)) This unfortunately doesn't work - when I delete a Rating, the according Subratings

[sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Aviv Giladi
Hey Stefano, I tried that, but when I did, this is the error I got while inserting a new rating: InterfaceError: (InterfaceError) Error binding parameter 0 - probably unsupported type. u'SELECT subratings.id AS subratings_id \nFROM subratings \nWHERE subratings.id = ?' (symbol 'NEVER_SET,) On

Re: [sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Stefano Fontanelli
Il 05/08/11 20.38, Aviv Giladi ha scritto: Hey Stefano, I tried that, but when I did, this is the error I got while inserting a new rating: InterfaceError: (InterfaceError) Error binding parameter 0 - probably unsupported type. u'SELECT subratings.id AS subratings_id \nFROM subratings \nWHERE

[sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Aviv Giladi
Hi Stefano, Thanks! The code is just like this: subrating_subratingproperty_association = Table('subrating_subratingproperty_association', Base.metadata, Column('subrating_id', Integer, ForeignKey('subratings.id')), Column('subrating_property_id', Integer,

[sqlalchemy] Re: Cascade Deletes

2011-08-04 Thread Aviv Giladi
Hey, Tried adding cascade to Rating's backref call like so: subrating = relationship(SubRating, backref=backref(rating, cascade=all, delete-orphan uselist=False)) This unfortunately doesn't work - when I delete a Rating, the according Subratings are NOT removed. What am I doing wrong?

Re: [sqlalchemy] Re: Cascade Deletes

2011-07-31 Thread Stefano Fontanelli
Il 30/07/11 23.24, Aviv Giladi ha scritto: Sorry, but I am really confused. Are you guys saying that on SQLite for example, cascade deletes don't work at all? Or do they work, but are less efficient? ONUPDATE/ONDELETE cascade - SQL expression: on SQLite and MySQL MyISAM doesn't work at all.

[sqlalchemy] Re: Cascade Deletes

2011-07-30 Thread Aviv Giladi
Thank you for your response. In that case, how do you manage these kinds of situations in SQLite and other engines in MySQL? Do you manually delete the children as well? On Jul 28, 10:35 am, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 28/07/11 01.15, Aviv Giladi ha scritto: Hi, I

Re: [sqlalchemy] Re: Cascade Deletes

2011-07-30 Thread Michael Bayer
SQLAlchemy's cascade='all, delete-orphan' implements the same CASCADE functionality as ONDELETE does, in Python. It is just less efficient since collections need to be fully loaded into memory for them to be processed. On Jul 30, 2011, at 1:49 PM, Aviv Giladi wrote: Thank you for your

[sqlalchemy] Re: Cascade Deletes

2011-07-30 Thread Aviv Giladi
Sorry, but I am really confused. Are you guys saying that on SQLite for example, cascade deletes don't work at all? Or do they work, but are less efficient? Thanks again! On Jul 30, 11:08 am, Michael Bayer mike...@zzzcomputing.com wrote: SQLAlchemy's cascade='all, delete-orphan' implements the

Re: [sqlalchemy] Re: Cascade Deletes

2011-07-28 Thread Stefano Fontanelli
Il 28/07/11 01.15, Aviv Giladi ha scritto: Hi, I am actually using both MySQL and SQLite (one on the dev machine, one on the server). Does that make a difference? ONDELETE and ONUPDATE don't work on SQLite and MySQL MyISAM. You must change your database to test them. In MySQL you can create

[sqlalchemy] Re: Cascade Deletes

2011-07-27 Thread Aviv Giladi
Hi, I am actually using both MySQL and SQLite (one on the dev machine, one on the server). Does that make a difference? On Jul 27, 12:26 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 25, 2011, at 9:47 AM, Aviv Giladi wrote: I can't seem to make cascade deletes work in

[sqlalchemy] Re: Cascade option, what does all mean?

2009-09-08 Thread Mike Conley
Your assumption should be correct. http://www.sqlalchemy.org/docs/05/reference/orm/mapping.html#sqlalchemy.orm.relation On Tue, Sep 8, 2009 at 6:40 AM, Eloff dan.el...@gmail.com wrote: Hi, I see cascade='all, delete, delete-orphan' in the tutorial, but I thought I read in the docs

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-03 Thread Gloria W
D'OH! (slaps head) Thanks for pointing this out, it makes perfect sense. I got it working by getting it from the DB, and merging it into the current session, then deleting: def DELETE(self,dmemberid): x = MemberInfo() memberProfile = x.GET(memberid=dmemberid,raw=True) merged_obj =

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-03 Thread Michael Bayer
Gloria W wrote: D'OH! (slaps head) Thanks for pointing this out, it makes perfect sense. I got it working by getting it from the DB, and merging it into the current session, then deleting: def DELETE(self,dmemberid): x = MemberInfo() memberProfile =

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-02 Thread Gloria W
Thanks for taking the time to respond. I still get an error, please see below. I show the record, just after a successful insert. I then show the error on delete. When I go into the db and manually delete these records, they exist as expected, and the deletion is successful. Thank you in

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-02-02 Thread Michael Bayer
this operation is illegal: def DELETE(self,memberid,fields=None): memberProfile = MemberProfile(memberID=memberid) self.session.delete(memberProfile) you must load MemberProfile from the database or merge() the above object into the session. On Feb 2, 2009, at 4:11 PM, Gloria W

[sqlalchemy] Re: cascade=all, delete, delete-orphan causes insert to fail

2009-01-28 Thread Michael Bayer
use all, delete cascade but not delete-orphan. On Jan 28, 1:06 pm, Gloria W strang...@comcast.net wrote: Hi again, I have a problem with a cascade relation. Any help or clues would be greatly appreciated. I have a model which has this relation:  member =

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread az
i think i had similar configuration, and i did it like one link was using default cascading, the other was just 'all'. but i'm not sure if yours is same, and any way i got mine via trial and error. do play with the cascade options. also i'm not sure if u apply some cascade on a backref what

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread GustaV
Is it planned for 0.6? or earlier? Anyway thanks: I stop trying all the combinations right now! :) On 15 jan, 18:30, Michael Bayer mike...@zzzcomputing.com wrote: There's various error conditions we should have added in 0.5 but have not. We should look into raising warnings in 0.5 and

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread Michael Bayer
i just committed the two warnings just now. On Jan 15, 2009, at 12:49 PM, GustaV wrote: Is it planned for 0.6? or earlier? Anyway thanks: I stop trying all the combinations right now! :) On 15 jan, 18:30, Michael Bayer mike...@zzzcomputing.com wrote: There's various error conditions we

[sqlalchemy] Re: cascade delete-orphan

2009-01-15 Thread GustaV
What is the best way to achieve the auto delete of the child then (refering to the example earlier)? I think about using an attribute extension... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] Re: cascade

2008-12-23 Thread Michael Bayer
ondelete and onupdate are keyword arguments within ForeignKey() itself, and they come out as part of the DDL when you call metadata.create_all(). On Dec 23, 2008, at 8:42 PM, justmike2...@gmail.com wrote: I seem to be running into a problem with implementing cascades in sqlalch. Next to

[sqlalchemy] Re: cascade

2008-12-23 Thread Michael Mileusnich
Yea I do the ondelete and onupdate in ForeignKey, creates tables and all but does not do the cascade or at least not in MSSQL. On Tue, Dec 23, 2008 at 7:42 PM, justmike2...@gmail.com justmike2...@gmail.com wrote: I seem to be running into a problem with implementing cascades in sqlalch.

[sqlalchemy] Re: cascade

2008-12-23 Thread Michael Bayer
generates the ON DELETE CASCADE in the DDL, versus the cascade does not work, are two different issues. Which are you experiencing, and if the latter, how is the issue manifesting itself ? Can you produce sample code which reproduces your issue ? On Dec 23, 2008, at 10:19 PM, Michael

[sqlalchemy] Re: cascade

2008-12-23 Thread Michael Mileusnich
code: queue_table = Table( 'QUEUES', metadata, Column('QUEUEID', Integer, autoincrement=True, primary_key=True), Column('JOBNUM', String(48), ForeignKey('JOBS.JOBNUM', onupdate=CASCADE, ondelete=CASCADE)), Column('SCHEDID', String(48),

[sqlalchemy] Re: cascade defaults

2008-09-25 Thread az
On Thursday 25 September 2008 04:30:19 Michael Bayer wrote: On Sep 24, 2008, at 6:23 AM, [EMAIL PROTECTED] wrote: hi i have cascade= option of relation switched automaticaly between all and other values, and nothing. so i used cascade=None as nothing, hoping it will get the default

[sqlalchemy] Re: cascade defaults

2008-09-25 Thread Michael Bayer
On Sep 25, 2008, at 3:03 AM, [EMAIL PROTECTED] wrote: I didn't think we had too much public API with the default=False thing going on but I havent taken a poll.Usually these defaults should just be documented. A symbol like DefaultValue might be nice except I don't see how that's any

[sqlalchemy] Re: cascade defaults

2008-09-24 Thread Michael Bayer
On Sep 24, 2008, at 6:23 AM, [EMAIL PROTECTED] wrote: hi i have cascade= option of relation switched automaticaly between all and other values, and nothing. so i used cascade=None as nothing, hoping it will get the default behaviour. the result was some query got 6x slower (actualy thats

[sqlalchemy] Re: cascade=all, delete-orphan = FlushError, instance is an unsaved, pending instance and is an orphan

2007-06-28 Thread svilen
On Thursday 28 June 2007 16:16:09 znerol wrote: Hi All Yes, i know, there is a FAQ-entry and i realized that this issue was discussed before. Regretably i'm not able to make things work with a one-to-many relationship using cascade=all, delete-orphan. Now i discovered that even the example

[sqlalchemy] Re: cascade=all, delete-orphan = FlushError, instance is an unsaved, pending instance and is an orphan

2007-06-28 Thread Michael Bayer
On Jun 28, 2007, at 9:16 AM, znerol wrote: Hi All Yes, i know, there is a FAQ-entry and i realized that this issue was discussed before. Regretably i'm not able to make things work with a one-to-many relationship using cascade=all, delete-orphan. Now i discovered that even the example

[sqlalchemy] Re: cascade=all, delete-orphan = FlushError, instance is an unsaved, pending instance and is an orphan

2007-06-28 Thread lorenz schori
Hi Again I was able to track down the issue. If the addresses attribute is replaced with a newly generated list containing all the items from the old list sqlalchemy apparently thinks that the elements are to be deleted (because the list was replaced) and marks them as orphan. Same

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Glauco
http://www.sqlalchemy.org/trac/wiki/ FAQ#FlushError:instancesomeinstanceisanunsavedpendinginstanceandisanorph an I think this is not Andreas an I too are searching to explain. The documentation is correct, and infact in tg-admin all go perfeclty.. but when the same example is gone from TG

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Andreas Jung
--On 16. Mai 2007 13:45:21 -0400 Michael Bayer [EMAIL PROTECTED] wrote: new to the FAQ: http://www.sqlalchemy.org/trac/wiki/ FAQ#FlushError:instancesomeinstanceisanunsavedpendinginstanceandisanorph an The FAQ does not explain the problem. Look at the real code: def

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Andreas Jung
--On 17. Mai 2007 10:16:17 +0200 Andreas Jung [EMAIL PROTECTED] wrote: --On 16. Mai 2007 13:45:21 -0400 Michael Bayer [EMAIL PROTECTED] wrote: This code causes the trouble. There is no save() operation involved - just a flush() operation driven by the Zope transaction integration of SA.

[sqlalchemy] Re: cascade='all, delete-orphan' causing error about unsaved, pending instances

2007-05-17 Thread Michael Bayer
On May 17, 2007, at 4:16 AM, Andreas Jung wrote: The FAQ does not explain the problem. Look at the real code: def importImagesFromFilesystem(self, lidx, imgdir): Import all images from a local filesystem into the staging area of the Medium. # get

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-14 Thread Nebur
On 14 Feb., 01:02, Michael Bayer [EMAIL PROTECTED] wrote: OK its fixed in r2314. the cascade from User.meta does take effect, This was fast ! I checked out r2314, and my old code (without delete-orphan) is working now. The only problem: I started to write a little beginners manual for the

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-13 Thread Nebur
On 12 Feb., 18:17, Luke Stebbing [EMAIL PROTECTED] wrote: Right, delete-orphan is what adds the lifecycle relationship between parent and child. It means that the child can't exist without a parent. That lets SA know that it should eliminate the child rather than trying to null out the

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-13 Thread Michael Bayer
OK its fixed in r2314. the cascade from User.meta does take effect, its just that the combination primary key/foreign key column on the t_userdata table was being blanked out when the deletion of the User took place, i.e. it was not checking first that the Userdata was also being deleted.

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-12 Thread Luke Stebbing
Right, delete-orphan is what adds the lifecycle relationship between parent and child. It means that the child can't exist without a parent. That lets SA know that it should eliminate the child rather than trying to null out the relationship. You probably want all so that all actions performed

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-11 Thread Luke Stebbing
See http://www.sqlalchemy.org/docs/ datamapping.myt#datamapping_relations_lifecycle I think you want a parent-child relationship between User and Userdata. Here's how I would change it (disclaimer: I'm new to SA myself): class User(object): pass class Userdata(object): pass ### we'll

[sqlalchemy] Re: Cascade-Delete causes AssertionError (Tries to blank-out primary key ...)

2007-02-11 Thread Nebur
Luke, your example is a great speed-up for me learning SA ! And my code is working fine now. I' m still looking what exactly makes the AssertionError disappear. (Well, your other changes (uselist=False etc.) are clearly an improvement. Still want to find out the cause of the error) The minimum

[sqlalchemy] Re: Cascade delete-orphan: child deleted althought still referenced ?

2006-12-19 Thread Michael Bayer
the orphan detection only supports one parent at a time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this

[sqlalchemy] Re: Cascade performance

2006-11-29 Thread Michael Bayer
i doubt this was any faster in previous releases since the basic metholodgy of cascade hasnt changed; when you attach object B to object A, it cascades the save-update operation across the entire graph represented by B. While there was one little fix a while back so that it wouldnt do cascade if

[sqlalchemy] Re: Cascade performance

2006-11-29 Thread Daniel Miller
Michael Bayer wrote: i doubt this was any faster in previous releases since the basic metholodgy of cascade hasnt changed Probably wasn't, I've just been testing with larger data sets lately. so ive added your test with an extra assertion that the session in fact contains 611 instances to

[sqlalchemy] Re: Cascade performance

2006-11-29 Thread Michael Bayer
well things like this, i.e. cascade not going over the same field of objects over and over again, are big and obvious. smaller things, its mostly the attributes package that adds the overhead in...i put that package through a huge overhaul some versions ago to simplify it, and i ran it

[sqlalchemy] Re: Cascade performance

2006-11-28 Thread Daniel Miller
Daniel Miller wrote: Lately I've been noticing severe slowness when instantiating new SA objects... Oh yeah, I forgot to mention that many of my class constructors take a parent object as one of their arguments, which explains the slow instantiation. cascade_test.py demonstrates that the