【发布时间】:2009-03-25 14:04:53
【问题描述】:
问题
我有一个使用 storm 0.14 的程序,它在 Windows 上给了我这个错误:
sqlite3.OperationError:数据库表被锁定问题是,在 linux 下它可以正常工作。
我的印象是它只有在完成一定数量的更改后才会发生,就像在某些代码中发生的那样,它会复制很多对象。
在 Windows 上打开调试模式会给我这个:
83 执行:'更新常规订单产品设置折扣=?在哪里常规order_product.order_id =? AND regularorder_product.product_id = ?', (Decimal("25.00"), 788, 274) 84 完成 85 执行:'更新重复订单集 nextDate=? WHERE repeat_orders.id = ?', (datetime.date(2009, 3, 31), 189) 86 错误:数据库表被锁定在 Linux 上:
83 执行:'更新常规订单产品设置折扣=?在哪里常规order_product.order_id =? AND regularorder_product.product_id = ?', (Decimal("25.00"), 789, 274) 84 完成 85 执行:'更新重复订单集 nextDate=? WHERE repeat_orders.id = ?', (datetime.date(2009, 3, 31), 189) 86 完成系统信息
Windows
- Windows XP SP 3
- Python 2.5.4
- NTFS 分区
Linux
- Ubuntu 8.10
- Python 2.5.2
- ext3 分区
一些代码
def createRegularOrderCopy(self):
newOrder = RegularOrder()
newOrder.date = self.nextDate
# the exception is thrown on the next line,
# while calling self.products.__iter__
# this happens when this function is invoked the second time
for product in self.products:
newOrder.customer = self.customer
newOrder.products.add(product)
return newOrder
orders = getRepeatedOrders(date)
week = timedelta(days=7)
for order in orders:
newOrder = order.createRegularOrderCopy()
store.add(newOrder)
order.nextDate = date + week
问题
sqlite3/python 在 windows 和 linux 之间有什么不同吗?这个错误可能是什么原因造成的,我该如何解决?
另一个观察
在发生错误的地方添加COMMIT时,会抛出此错误:sqlite3.OperationalError: cannot commit transaction - SQL statements in progress
答案的答案
我没有使用多个线程/进程,因此并发应该不是问题,而且我只有一个 Store 对象。
【问题讨论】:
标签: python windows linux sqlite