peewee savepoint不存在

时间:2016-06-16 23:19:43

标签: python mysql multithreading peewee

我使用peewee连接MySQL数据库。我有一个条目列表,必须插入数据库并更新,以防它们已经存在。我正在使用create_or_get功能。我还使用线程来加速这个过程;代码如下所示:

# pool is just a map wrapper around standard threading module
pool  = utils.ThreadPool()
    for page in xrange(0, pages):
        pool.add_task(self.update_page, page)
pool.wait_completion()

def update_page(self, num):
    for entry in self.get_entries_from_page(num):
        self.push_entry(entry)

def push_entry(self, entry):
    with _db.execution_context():
        result, new = EntryModel.create_or_get(**entry) # << error  here
        if not new :
            if entry['date'] > result.date:
                result.hits += 1
                result.date = track['date']
                result.save()

数据库初始化:

_db.initialize(playhouse.pool.PooledMySQLDatabase(n, user = u, passwd = w, host = h, port = p))

一切都在顺利进行,但突然间,我开始在上述行中收到很多错误: (1305, 'SAVEPOINT s449cd5a8d165440aaf47b205e2932362 does not exist')

每次保存点编号都会更改,并且数据未写入数据库。重新创建数据库没有帮助。什么可能导致这个错误?

0 个答案:

没有答案