Python SQLite:数据库被锁定 [英] Python SQLite: database is locked

查看:60
本文介绍了Python SQLite:数据库被锁定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试此代码:

import sqlite

connection = sqlite.connect('cache.db')
cur = connection.cursor()
cur.execute('''create table item
  (id integer primary key, itemno text unique,
        scancode text, descr text, price real)''')

connection.commit()
cur.close()

我发现了这个异常:

Traceback (most recent call last):
  File "cache_storage.py", line 7, in <module>
    scancode text, descr text, price real)''')
  File "/usr/lib/python2.6/dist-packages/sqlite/main.py", line 237, in execute
    self.con._begin()
  File "/usr/lib/python2.6/dist-packages/sqlite/main.py", line 503, in _begin
    self.db.execute("BEGIN")
_sqlite.OperationalError: database is locked

cache.db 权限没问题.有什么想法吗?

Permissions for cache.db are ok. Any ideas?

推荐答案

原来问题是因为 db 文件的路径实际上是一个 samba 挂载目录.我移动了它并开始工作.

Turned out the problem happened because the path to the db file was actually a samba mounted dir. I moved it and that started working.

这篇关于Python SQLite:数据库被锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆