Python扭曲和数据库连接 [英] Python Twisted and database connections

查看:125
本文介绍了Python扭曲和数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的工作项目包括同步应用程序(短期)和异步Twisted应用程序(长期使用)。我们正在重新考虑我们的数据库,并将构建一个API模块来解耦该模块中的所有SQL。我想创建该API,所以同步和异步应用程序都可以使用它。对于同步应用程序,我想调用数据库API只是返回数据(阻塞)就像使用MySQLdb,但对于异步应用程序,我想调用相同的API函数/方法是非阻塞的,可能返回推迟。任何人都有任何提示,建议或帮助,他们可能会提供给我这样做?
提前感谢,
Doug

Our projects at work include synchronous applications (short lived) and asynchronous Twisted applications (long lived). We're re-factoring our database and are going to build an API module to decouple all of the SQL in that module. I'd like to create that API so both synchronous and asynchronous applications can use it. For the synchronous applications I'd like calls to the database API to just return data (blocking) just like using MySQLdb, but for the asynchronous applications I'd like calls to the same API functions/methods to be non-blocking, probably returning a deferred. Anyone have any hints, suggestions or help they might offer me to do this? Thanks in advance, Doug

推荐答案

twisted.enterprise.adbapi 似乎要走 - 你认为它不能满足你的要求,如果是这样,你能解释为什么吗?

twisted.enterprise.adbapi seems the way to go -- do you think it fails to match your requirements, and if so, can you please explain why?

这篇关于Python扭曲和数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆