Hello.

I'm using SQL Alchemy as a persistence  engine for my multi-threaded
desktop application with sqlite backend.

ScopedSession acts very well, but there is a problem:

1) I have 2 tables:

categories_table = Table('category', metadata,
    Column('id', Integer, primary_key=True),
    Column('name', Unicode(50)),
    )

keywords_table = Table('keyword', metadata,
    Column('id', Integer, primary_key=True),
    Column('category_id', Integer, ForeignKey('category.id')),
    Column('text', Unicode(200)),
    )

mapper(Category, categories_table,properties={
    'keywords': relation(Keyword,
backref='category',order_by=keywords_table.c.text,cascade="all, delete-
orphan")
})


mapper(Keyword, keywords_table)

2) Thread A creates Keyword instance with something like this:
      new_keyword = Keyword(u'Test',category=category)

   Newly created `new_keyword` automagically become attached to
`category` session manager.

   But not being automagically commited!

   `category` may be created in other thread, so calling session.flush
() does nothing because new object doesn't belong to current session.

3) It will remain uncommited when i'm closing my application. And if
finally get lost after application exit.


So the question is:

How to flush *ALL* sessions, regardless their threads?

--~--~---------~--~----~------------~-------~--~----~
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 group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to