[Twisted-Python] is it possible to use an ORM in Twisted?

Phil Mayers p.mayers at imperial.ac.uk
Mon Feb 12 06:20:02 EST 2007

slowtech chen wrote:
> Hey guys,
> I know there is adbapi to do database operations for twisted. The way 
> adbapi works is similar to deferToThread in some ways, I guess the 
> difference is adbapi handles some thread issues automatically, and 
> provides a connection pool. So here comes my question:
>     Is it possible to use an ORM by calling deferToThread(ORM 
> operations...),  it seems to me that if you take care of the thread 
> issues, this is doable. Even so I  have no any clue though :).
> I am new to Twisted and the above is my confusion, any suggestion very 
> welcome.

It can be done, but they don't "look" the same as ORMs in blocking code:


If you can afford to use a local SQLite database, there's also:


The key difficulty is that the ORM either needs to be very, very fast to 
avoid blocking when fetching the (potentially arbitrarily large) graph 
of objects from the database, or you need to fetch them in a separate thread

More information about the Twisted-Python mailing list