[Twisted-Python] SQLAlchemy integration

Manlio Perillo manlio_perillo at libero.it
Thu Nov 23 04:33:50 EST 2006

glyph at divmod.com ha scritto:
> On 22 Nov, 11:19 am, manlio_perillo at libero.it wrote:
>>I'm writing some modules for integrating SQLALchemy with Twisted.
>>The idea is to write a custom Pool, EngineStrategy and Engine for Twisted.
>>I would like to know if there are some other people working on this
>>(excluding sAsync)
> Is there really a good reason for having *two* different efforts to
> integrate Twisted with a single other library?  Surely it must be
> possible to collaborate somehow.

I'm tring to offer an interface compatible with the twisted adbapi.
Moreover my API is very different from sAsync:

# global_connect will bind the engine to the global default_metadata
engine = Engine(...., global_connect=True)

users = Table("users, column(.....))

select([users], ...).addCallback()


This works because Engine implements the Connectable interface.
There is an issue here: if a query/table is bound to this Engine, every
query will run in a separate thread; this is not what one want when
inside a transaction).

More complex is the integration with sqlalchemy session handling.

As an example with Nevow:
- a thread retrieve an object from the database
- another thread modify the object

It would be much simple if the two operations occur in the same thread
(this require to run renderHTTP or locateChild in a separate thread but
I ignore if this is safe).

Regards  Manlio Perillo

More information about the Twisted-Python mailing list