[sqlalchemy] Load parent on child deletion

2012-03-21 Thread Pau Tallada
Hi! I have a model with a parent-child relationship on the same entity. The children collection on a parent instance has events set to intercept adding and removing instances to/from it. This is needed to update an attribute from the parent instance. But when I delete an instance which is the

[sqlalchemy] with_lockmode('share') ?

2012-03-21 Thread Julien Cigar
Hello, I'm using SQLAlchemy 0.7.6 and PostgreSQL 9.0.7 which support a FOR UPDATE and a FOR SHARE clause to lock selected rows. I noticed that the .with_lockmode() method of the Query object

[sqlalchemy] Single table inheritance

2012-03-21 Thread Kent
Hoping for advice: I'm using sqlalchemy against a legacy application's database design, most of which isn't in my control. I have a situation where single table inheritance should work beautifully but there is one catch: of the 7 polymorphic sub classes, there is one which is allowed to

Re: [sqlalchemy] Single table inheritance

2012-03-21 Thread Michael Bayer
On Mar 21, 2012, at 9:49 AM, Kent wrote: Hoping for advice: I'm using sqlalchemy against a legacy application's database design, most of which isn't in my control. I have a situation where single table inheritance should work beautifully but there is one catch: of the 7 polymorphic sub

Re: [sqlalchemy] with_lockmode('share') ?

2012-03-21 Thread Michael Bayer
the PG dialect has only FOR UPDATE and FOR UPDATE NOWAIT at the moment, easy enough to add more options though it would be helpful if someone could volunteer a patch on it (with tests as always!): http://www.sqlalchemy.org/trac/ticket/2445 On Mar 21, 2012, at 6:00 AM, Julien Cigar wrote:

Re: [sqlalchemy] Load parent on child deletion

2012-03-21 Thread Michael Bayer
On Mar 21, 2012, at 5:18 AM, Pau Tallada wrote: Hi! I have a model with a parent-child relationship on the same entity. The children collection on a parent instance has events set to intercept adding and removing instances to/from it. This is needed to update an attribute from the

Re: [sqlalchemy] with_lockmode('share') ?

2012-03-21 Thread Julien Cigar
Hi Mike, I would be happy to provide a patch (when I find some time). I never made any patch for SQLAlchemy, what's the preferred method to do it? Attach an `hg diff` to the ticket or a pull request on Bitbucket .. ? Thanks, Julien On 03/21/2012 15:08, Michael Bayer wrote: the PG dialect

Re: [sqlalchemy] Single table inheritance

2012-03-21 Thread Kent Bower
That will work for me, thanks! P.S. make a note that the doc statement that it will be a future release should be updated. On 3/21/2012 10:04 AM, Michael Bayer wrote: also polymorphic_on can be any SQL expression in 0.7, like a CASE statement if you wanted. -- You received this message

Re: [sqlalchemy] Single table inheritance

2012-03-21 Thread Michael Bayer
On Mar 21, 2012, at 10:29 AM, Kent Bower wrote: That will work for me, thanks! P.S. make a note that the doc statement that it will be a future release should be updated. can you point me right to where it says that On 3/21/2012 10:04 AM, Michael Bayer wrote: also polymorphic_on

Re: [sqlalchemy] Load parent on child deletion

2012-03-21 Thread Pau Tallada
Yes, I meant that :P I'll try with the before_flush_event. Thanks!! 2012/3/21 Michael Bayer mike...@zzzcomputing.com On Mar 21, 2012, at 5:18 AM, Pau Tallada wrote: Hi! I have a model with a parent-child relationship on the same entity. The children collection on a parent instance has

[sqlalchemy] Re: Access denied for user error

2012-03-21 Thread shinriyo
I tried sqlit. it is fine. engine = create_engine('sqlite+pysqlite:///file.db') but, MySQL can't connect. 2012年3月21日水曜日12時46分23秒 UTC+9 shinriyo: Hi there I use sqlalchemy and Python3.2 and pymysql on Windows7. I tried below from sqlalchemy import * engine =

Re: [sqlalchemy] Re: Access denied for user error

2012-03-21 Thread Michael Bayer
it seems like you connect without a host using mysql.exe, so try: create_engine('mysql+pymysql://teaspoon:teaspoon@/teaspoon') otherwise you need to add an entry for 'teaspoon'@'localhost' to your user table: http://dev.mysql.com/doc/refman/5.0/en/connection-access.html On Mar 21, 2012, at

Re: [sqlalchemy] Re: Access denied for user error

2012-03-21 Thread shinriyo
* Hi Michael Bayer Thank you for your help. I tried to change create_engine args you suggested below. create_engine('mysql+pymysql://teaspoon:teaspoon@/teaspoon') But, same problem was happened. So, I create user table like the URL you tought me. --- CREATE TABLE user ( user VARCHAR(64),