-->

SQLAlchemy and Twisted

2020-03-05 02:09发布

问题:

I'v learned twisted for somewhile and would like to do some network communication and local db operation as well.BTW, MySQL DB adopted, non-blocking required and perferred.

Someone told me that sqlalchemy is just great. But as far as I have known from the Internet, the two may not work together perfectly(http://twistedmatrix.com/pipermail/twisted-python/2009-March/019359.html ).

So I would like to know if anyone has this kind of experience(either successful or a failure is welcomed) to make both of them work together?

And Could anyone tell why there is no way for them to work together?

Thank you in advance!

回答1:

SQLAlchemy presents a blocking interface to database access. You can use it with Twisted if you use it in a separate thread. It's frequent to use many threads with SQLAlchemy anyway, so there's nothing really special going when you try to use it with Twisted. It only seems strange because Twisted itself mostly offers APIs which you don't need threads for.