使用SQLObject的简单多线程处理

2024-03-28 17:34:50 发布

您现在位置:Python中文网/ 问答频道 /正文

一旦我执行.getOne(),它就会停止工作:

from sqlobject import *
import threading

sqlhub.processConnection = connectionForURI('mysql://user:password@localhost:3306/database')

class Player(SQLObject):
    name = StringCol(length=64)
    last_login = DateTimeCol()
    create_date = DateTimeCol(default=DateTimeCol.now)

def act():
    result = Player.selectBy(name='Zippo')
    player = result.getOne()
    print 'You will never see this message in console.'

threading.Thread(target=act).start()

Tags: namefromimportmysqlresultactplayerthreading
2条回答

会不会有人摔倒了,而你却没有看到例外?在这种情况下,可以将默认结果指定为参数,也可以将其放入try/except子句中。在

如果在调试器中运行它会发生什么?在

因为我们不知道你的数据库里有什么,所以这里没有太多的信息。在

不幸的是,这个问题与SQLObject或Python无关。可能是我的电脑或者MySQL服务器。对不起,我错问了大家。在

相关问题 更多 >