RE: [sqlalchemy] How do you handle threading issues?

2009-12-19 Thread Kevin Ar18
The method that works 95% of the time is, just establish a connection to the database, start a transaction, do some work that stays within the thread, commit the transaction. Then throw all loaded state in that thread away, and reload it all on the next transaction. Its only if you

Re: [sqlalchemy] Re: DeclarativeBase and multiple inheritance - a better solution

2009-12-19 Thread Michael Bayer
Hey guys - I forgot about the really obvious way to do this - class decorators: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() def common_columns(cls): cls.created_at = Column(DateTime,

[sqlalchemy] Re: sqlite and thread

2009-12-19 Thread drakkan
On 16 Dic, 19:03, Michael Bayer mike...@zzzcomputing.com wrote: drakkan wrote: Hi, connectionstring = 'sqlite:///' + settings.DATABASE_PATH+'? check_same_thread=False' #engine = create_engine(connectionstring, echo=settings.DEBUG, echo_pool=settings.DEBUG) engine =

Re: [sqlalchemy] Re: sqlite and thread

2009-12-19 Thread Michael Bayer
On Dec 19, 2009, at 4:50 PM, drakkan wrote: On 16 Dic, 19:03, Michael Bayer mike...@zzzcomputing.com wrote: drakkan wrote: Hi, connectionstring = 'sqlite:///' + settings.DATABASE_PATH+'? check_same_thread=False' #engine = create_engine(connectionstring, echo=settings.DEBUG,

[sqlalchemy] Re: sqlite and thread

2009-12-19 Thread drakkan
On 20 Dic, 00:03, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 19, 2009, at 4:50 PM, drakkan wrote: On 16 Dic, 19:03, Michael Bayer mike...@zzzcomputing.com wrote: drakkan wrote: Hi, connectionstring = 'sqlite:///' + settings.DATABASE_PATH+'? check_same_thread=False'

Re: [sqlalchemy] Re: sqlite and thread

2009-12-19 Thread Michael Bayer
On Dec 19, 2009, at 6:20 PM, drakkan wrote: Sorry, I don't fully understand you answer: I have a main application that start a new thread to do a long running task, while the thread is running the main app do other things and when it commit the changes the thread has an exception caused

[sqlalchemy] Re: sqlite and thread

2009-12-19 Thread drakkan
Thanks I found my error: I defined my session as scoped session but in a global file I was redefining it as session=sess() and session was not more scoped On 20 Dic, 00:37, Michael Bayer mike...@zzzcomputing.com wrote: On Dec 19, 2009, at 6:20 PM, drakkan wrote: Sorry, I don't fully