【问题标题】:Locking MySQL tables not working in Tornado锁定 MySQL 表在 Tornado 中不起作用
【发布时间】:2013-03-20 15:54:44
【问题描述】:

我有这个代码:

# Retreive the users that can obtain permission on the network except the admin
self.lock_tables("read", ['nets_permissions as n', 'users as u'])
usrs = self.db.query("SELECT distinct u.id FROM users as u \
        left outer join nets_permissions as n on u.id = n.user_id \
        where u.id not in \
        (select users.id from users left outer join nets_permissions \
        on users.id = nets_permissions.user_id \
        where nets_permissions.network_id=%s and nets_permissions.perm=3)", netid)
self.unlock_tables()

但我在 Tornado 屏幕中收到此错误:

文件“./wsn.py”,第 571 行,在 get 其中 nets_permissions.network_id=%s 和 nets_permissions.perm=3)", netid) raise errorclass, errorvalue OperationalError: (1100, "Table 'users' is not locked with LOCK TABLES")

哪里出错了?

【问题讨论】:

  • lock_tables 看起来像罪魁祸首;它看起来也是你的代码,而不是 Tornado。

标签: mysql locking tornado


【解决方案1】:

解决办法是:

# Retreive the users that can obtain permission on the network except the admin
    self.lock_tables("read", ['nets_permissions as n', 'users as u', 'nets_permissions as m', 'users as v'])
    usrs = self.db.query("SELECT distinct u.id FROM users as u \
                          left outer join nets_permissions as n on u.id = n.user_id \
                          where u.id not in \
                          (select v.id from users as v left outer join nets_permissions as m \
                          on v.id = m.user_id \
                          where m.network_id=%s and m.perm=3)", netid)
    self.unlock_tables()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-06
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    相关资源
    最近更新 更多