[sqlalchemy] Unexpected Behavior for ondelete='CASCADE' in Postgres

2010-12-10 Thread zende
Assuming I define my tables using the following: CREATE TABLE users ( id SERIAL NOT NULL, username VARCHAR(255) NOT NULL, PRIMARY KEY (id), UNIQUE (username) ) CREATE TABLE posts ( id SERIAL NOT NULL, title VARCHAR(255) NOT NULL, body TEXT NOT NULL, user_id INTEGER, PRIMARY KEY (id), FOREIGN KEY(

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
nope. Jason was right :D. I needed to add Session.remove() to my threads as well; though, I'm not sure why adding expires_on_commit=False alone didn't solve it. Oh well, works now Thanks! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
Jason, in the contrived example I came up with and posted, your solution worked but not in my tests. I tried both expires_on_commit=False and Session.remove() before the drop with no luck. Thanks for the suggestion On Jul 8, 10:03 am, jason kirtland wrote: > Your scoped session still has an act

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
Mariano, What db? postgres? On Jul 8, 9:41 am, Mariano Mara wrote: > I'm on a similar situation. For lack of time I couldn't investigate it > yet but I have a drop_all when running nosetests in my pylons project > and it get stuck while dropping the tables. I have to kill the process, > because

[sqlalchemy] Re: blocking on Base.metadata.drop_all() in test

2010-07-08 Thread zende
I reproduced the issue the script below: http://gist.github.com/468199 Sorry for the weak explanation before. This has little to do with being "in tests" except that's the only code that drops and creates the db for any reason. Ctrl-C does nothing when it blocks. Chris, try running the script i

[sqlalchemy] blocking on Base.metadata.drop_all() in test

2010-07-07 Thread zende
Base.metadata.drop_all() completely blocks in the tearDown method of some of my tests. Session is defined with scoped_session(sessionmaker()) Any ideas how to get around this? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group

[sqlalchemy] Seeding a Database with Data

2010-06-09 Thread zende
What's the best way to seed a db with data? I've used DDL.execute_at('after-create', table) in the past, but is there a way to get bind.create to run a segment of code first? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group,

[sqlalchemy] Re: Detaching Relation Objects for Purpose of Serialization

2009-12-18 Thread zende
nevermind :( poet.__dict__.pop('poems') -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For

[sqlalchemy] Detaching Relation Objects for Purpose of Serialization

2009-12-18 Thread zende
How do I detach or unload the data from a relation on an instance? I'm writing a thin layer on top of SA for caching and need to do serialization. The following happens when serializing: poet = session.query(Poet).find_by(name='Haafez').one() pickle.dumps(poet) # Only serializes the Poet object

[sqlalchemy] Re: Cache Invalidation. Alternatives to MapperExtension?

2009-12-18 Thread zende
@michael: changed to after_commit @ivan: Sorry for the late reply. Here's a decent example. I have this working in production error free, but it's hardly done. Note, the code below is a specific example. Let me know if you have questions from sqlalchemy import orm def get_session_id(session)

[sqlalchemy] Re: Cache Invalidation. Alternatives to MapperExtension?

2009-12-14 Thread zende
I used SesionExtension.after_flush. Worked great. Thanks for the help Michael! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlal

[sqlalchemy] Cache Invalidation. Alternatives to MapperExtension?

2009-12-14 Thread zende
I wrote a simple layer on top of my models that allows them to be easily inserted into and fetched from memcache. Now, I'm trying to solve the easier part :) -- cache invalidation. I can use mapper extensions, but I'm looking for a cleaner way. The biggest problem with MapperExtension is that so