admin 管理员组文章数量: 1086019
2024年4月13日发(作者:易语言自动加入域脚本)
def run(self):
if mmit:
conn = t(me, isolation_level=None, check_same_thread=False)
else:
conn = t(me, check_same_thread=False)
e('PRAGMA journal_mode = %s' % l_mode)
_factory = str
cursor = ()
e('PRAGMA synchronous=OFF')
while True:
req, arg, res = ()
if req == '--close--':
break
elif req == '--commit--':
()
else:
e(req, arg)
if res:
for rec in cursor:
(rec)
('--no more--')
if mmit:
()
()
def execute(self, req, arg=None, res=None):
"""
`execute` calls are non-blocking: just queue up the request and return immediately.
"""
((req, arg or tuple(), res))
def executemany(self, req, items):
for item in items:
e(req, item)
def select(self, req, arg=None):
"""
Unlike sqlite's native select, this select doesn't handle iteration efficiently.
The result of `select` starts filling up with values as soon as the
request is dequeued, and although you can iterate over the result normally
(`for res in (): ...`), the entire result will be in memory.
"""
res = Queue() # results of the select will appear as items in this queue
e(req, arg, res)
while True:
rec = ()
if rec == '--no more--':
break
yield rec
def select_one(self, req, arg=None):
"""Return only the first row of the SELECT, or None if there are no matching rows."""
try:
return iter((req, arg)).next()
except StopIteration:
return None
def commit(self):
e('--commit--')
def close(self):
e('--close--')
#endclass SqliteMultithread
版权声明:本文标题:python操作sqlite示例(支持多进程线程同时操作) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1712959672a614341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论