Is there any async driver / module for MySQL that can be used on Tornado to support transactions?

Is there any async driver / module for MySQL that can be used on Tornado to support transactions? I am writing a Tornado application with MySQL as a database. I googled and found https://github.com/woshifyz/tornado-mysql

https://github.com/hybridlogic/txMySQL

but transaction support is missing.

+4
source share
1 answer

Tornado's proprietary database module supports transactions just fine.

class Application(tornado.web.Application): def __init__(self): handlers = [ (r'/', someHandler), ] tornado.web.Application.__init__(self, handlers) self.db = tornado.database.Connection( host=mysql_host, database=mysql_db, user=mysql_user, password=mysql_password) # ---------------------- class someHandler(tornado.web.RequestHandler): def get(self): # ... try: self.application.db.execute('START TRANSACTION') row = self.application.db.get("SELECT ...", ...) # ... self.application.db.execute("INSERT ...", ...) self.application.db.execute("COMMIT") except Exception, e: self.set_status(500) return # ... 

However, it does not support asynchronous calls.

UPDATE (May 2015)

Several updates to the topic.

  • The Tonado DB driver has been excluded from the project. It is available as a separate library named torndb (available here ).
  • These projects may be of interest: TorMySQL , Tornado-MySQL , AsyncTorndb .
+1
source

Source: https://habr.com/ru/post/1494315/


All Articles