[sqlalchemy] Delete failing with StaleDataError

2012-02-11 Thread Fayaz Yusuf Khan
The attached script fails with this: Traceback (most recent call last): File stale_delete.py, line 33, in module session.flush() File /usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py, line 1559, in flush self._flush(objects) File

Re: [sqlalchemy] user defined type

2012-02-11 Thread werner
Just for the archive, On 08/02/2012 16:47, Michael Bayer wrote: @hybrid_property def namesandvar(self): nVar = self.name if self.name2: nVar += ', ' + self.name2 if self.variety: nVar += ', ' + self.variety return nVar I must be

[sqlalchemy] HOW TO HANDLE SPECIAL CHARACTERS WITH ENGINE.EXECUTE

2012-02-11 Thread Krishnakant Mane
Hello all, I have an interesting problem for which I am sure some simple solution must be existing. I have made a Python function which I will paist below. Basically what the function does is that it takes 3 parameters, namely the name of a stored procedure, engine instance and a set of

[sqlalchemy] Can I access session.identity_map? Or is there a better way to do this?

2012-02-11 Thread Kai Jia
Hi, The situation is that I have tow tables (User and UserGrp) and two association tables (one for many-to-many between User and UserGrp, one for many-to-many between UserGrp and user group permissions). Each user can belong to multiple user groups, and each user group can have multiple

Re: [sqlalchemy] Delete failing with StaleDataError

2012-02-11 Thread Michael Bayer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Feb 11, 2012, at 5:22 AM, Fayaz Yusuf Khan wrote: The attached script fails with this: Traceback (most recent call last): File stale_delete.py, line 33, in module session.flush() File

Re: [sqlalchemy] HOW TO HANDLE SPECIAL CHARACTERS WITH ENGINE.EXECUTE

2012-02-11 Thread Michael Bayer
On Feb 11, 2012, at 8:02 AM, Krishnakant Mane wrote: Hello all, I have an interesting problem for which I am sure some simple solution must be existing. I have made a Python function which I will paist below. Basically what the function does is that it takes 3 parameters, namely the name

Re: [sqlalchemy] Can I access session.identity_map? Or is there a better way to do this?

2012-02-11 Thread Michael Bayer
On Feb 11, 2012, at 7:04 AM, Kai Jia wrote: Hi, The situation is that I have tow tables (User and UserGrp) and two association tables (one for many-to-many between User and UserGrp, one for many-to-many between UserGrp and user group permissions). Each user can belong to multiple user

Re: [sqlalchemy] Delete failing with StaleDataError

2012-02-11 Thread Fayaz Yusuf Khan
On Saturday 11 Feb 2012 10:32:12 AM Michael Bayer wrote: I ran this and indeed InnoDB appears to be broken here. This is a MySQL bug. It would appear it is running the cascade between the two A rows and only considering the lead object to be the one deleted.Can't exactly find it at

Re: [sqlalchemy] HOW TO HANDLE SPECIAL CHARACTERS WITH ENGINE.EXECUTE

2012-02-11 Thread Krishnakant Mane
Thanks Michael, I will see if this works perfectly with postgresql. I had tryed func before but did not get any success. May be this time it will work. Happy hacking. Krishnakant. On 11/02/12 21:10, Michael Bayer wrote: On Feb 11, 2012, at 8:02 AM, Krishnakant Mane wrote: Hello all, I have an

[sqlalchemy] Set-based association proxy through AppenderQuery?

2012-02-11 Thread Mark Friedenbach
Hi, Is it possible to have an association_proxy (in the association object pattern) that emulates a set-based collection if it goes through a lazy='dynamic' relationship? I can't for the life of me find a way to make this work (setting collection_class on the dynamic relationship doesn't seem to

Re: [sqlalchemy] Can I access session.identity_map? Or is there a better way to do this?

2012-02-11 Thread Kai Jia
The reason why I used a in-database cache is that the group permissions are not often changed, so when a user logs in, I can know its permissions without querying the other three tables. And I used a in-memory cache because it's quite frequent to check user permissions, so I do not have to