[sqlalchemy] Re: Cascade Deletes

2011-08-08 Thread Aviv Giladi
are objects that have a relationship with Rating. When I remove these assignments, everything works fine. Does this ring any bells? On Aug 7, 1:15 pm, Stefano Fontanelli s.fontane...@asidev.com wrote: Il 07/08/11 20.08, Aviv Giladi ha scritto: I see. Where can I start looking

[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

[sqlalchemy] Re: Cascade Deletes

2011-08-06 Thread Aviv Giladi
subrating1 and subrating3, but not subrating2. How do I avoid this error? On Aug 6, 6:16 am, Stefano Fontanelli s.fontane...@asidev.com wrote: 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

[sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Aviv Giladi
,) On Aug 5, 9:46 am, Stefano Fontanelli s.fontane...@asidev.com wrote: 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

[sqlalchemy] Re: Cascade Deletes

2011-08-05 Thread Aviv Giladi
, and the Rating is gone, but the SubRating is still there. The DB shows that the Rating has the correct Subrating's ID.. On Aug 5, 11:45 am, Stefano Fontanelli s.fontane...@asidev.com wrote: 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

[sqlalchemy] Re: Cascade Deletes

2011-08-04 Thread Aviv Giladi
? (Testing with SQLite) On Jul 31, 9:01 am, Stefano Fontanelli s.fontane...@asidev.com wrote: 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

[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

[sqlalchemy] Re: Cascade Deletes

2011-07-30 Thread Aviv Giladi
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 response. In that case, how do you manage

[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

[sqlalchemy] Cascade Deletes

2011-07-25 Thread Aviv Giladi
I can't seem to make cascade deletes work in sqlalchemy. I have a parent class (called Rating), a sub class (Subrating) and a third class called SubRatingProperty. There is a one-to-one relationship between Rating and SubRating - each Rating can only have one specific SubRating object. Next, the

[sqlalchemy] Best design for commits?

2011-04-20 Thread Aviv Giladi
Hey guys, I have a Pylons back-end running on SQLAlchemy. I have a script that reads a tree of XML files from an HTTP server (it downloads an xml X, and then downloads that X's children, and then iterates the children, and so forth in recursion). Each xml file represents an SQLAlchemy model. The

[sqlalchemy] Re: Best design for commits?

2011-04-20 Thread Aviv Giladi
Dear Rick, Thank you for your reply. I understand, but is there not a better way than doing a lot of single commits in case of a commit exception? In other words, is there a way to tell SQLAlchemy to throw an exception on the Session.add if there's a duplicate as opposed to on the Session.commit?

[sqlalchemy] Re: Best design for commits?

2011-04-20 Thread Aviv Giladi
I agree, but the thing is that committing every 10 entries is a little low for me, I was thinking of around 50, at which case having 50 individual commits is quite costly.. In case I choose the implement your method, how would you go about it? How do you keep objects of the last 50 or whatever

[sqlalchemy] Re: Best design for commits?

2011-04-20 Thread Aviv Giladi
Thanks again Rick. The issue is that I have a LOT of duplicates (around 20-30%) - that's just how that tree is structured. Therefore, I think I am going to go with catching DB exceptions regardless, but also use an indexed collection to prevent duplicates. Cheers! On Apr 20, 12:43 pm, Richard

[sqlalchemy] Best way to insert different string to Unicode columns?

2011-04-20 Thread Aviv Giladi
Hey guys, I have a SQLAlchemy model with a Unicode column. I sometimes insert unicode values to it (u'Value'), but also sometimes insert ASCII strings. What is the best way to go about this? When I insert ASCII strings with special characters I get this warning: SAWarning: Unicode type

[sqlalchemy] Re: Best design for commits?

2011-04-20 Thread Aviv Giladi
Thank you for your responses everyone. I have one more question - the really time heavy task here is retrieving the URLs over HTTP (it takes almost a second per URL). I am using urllib3 that has connection pooling, but other than that, is there any other way to speed this up? Perhaps

[sqlalchemy] Re: Error with Adjacency List Relationship Implementation

2011-04-19 Thread Aviv Giladi
Figured it out, I was being retarded. Thanks! On Apr 19, 7:33 pm, Aviv Giladi avivgil...@gmail.com wrote: Hey guys, I am playing around with SQLAlchemy (over Pylons) and encountering a strange problem. I am using the adjacency list relationship concept to represent nodes and their parents

[sqlalchemy] Self-referencing Table Cannot Have 0 as Primary Index?

2011-04-19 Thread Aviv Giladi
Hey guys, I encountered a very strange problem with SQLAlchemy. I have a model that is self-referencing (adjacency list relationship). I simply copied the model (Node) from the SQLAlchemy tutorial. Here is the model's code: class Node(Base): __tablename__ = 'nodes' id =