本文整理汇总了Python中Data.DB.commit方法的典型用法代码示例。如果您正苦于以下问题:Python DB.commit方法的具体用法?Python DB.commit怎么用?Python DB.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.DB
的用法示例。
在下文中一共展示了DB.commit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: removeSelected
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def removeSelected(self):
cats, texts = self.getSelected()
DB.executemany("delete from text where rowid = ?",
map(lambda x:(x, ), texts))
self.removeUnused()
self.update()
DB.commit()
示例2: cleanup
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def cleanup(self):
day = 24*60*60
now = time.time()
q = []
self.progress_.show()
for grp, lim in [(30.0, Settings.get('group_month')),
(7.0, Settings.get('group_week')),
(1.0, Settings.get('group_day'))]:
w = now - day*lim
g = grp * day
q.extend(DB.fetchall('''
select avg(w), data, type, agg_mean(time, count), sum(count), sum(mistakes), agg_median(viscosity)
from statistic where w <= %f
group by data, type, cast(w/%f as int)''' % (w, g)))
self.progress_.inc()
DB.execute('''delete from statistic where w <= ?''', (w, ))
self.progress_.inc()
DB.executemany('''insert into statistic (w, data, type, time, count, mistakes, viscosity)
VALUES (?, ?, ?, ?, ?, ?, ?)''', q)
self.progress_.inc()
DB.execute('vacuum')
self.progress_.inc()
DB.commit()
self.progress_.hide()
示例3: setImpList
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def setImpList(self, files):
self.sender().hide()
self.progress.show()
for x in map(unicode, files):
self.progress.setValue(0)
fname = path.basename(x)
lm = LessonMiner(x)
self.connect(lm, SIGNAL("progress(int)"), self.progress.setValue)
self.addTexts(fname, lm, update=False)
self.progress.hide()
self.update()
DB.commit()
示例4: addTexts
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def addTexts(self, source, texts, lesson=None, update=True):
id = DB.getSource(source, lesson)
r = []
for x in texts:
x = re.sub(Settings.get('sentence_strip'), ' ', x)
h = hashlib.sha1()
h.update(x.encode('utf-8'))
txt_id = h.hexdigest()
dis = 1 if lesson == 2 else None
try:
DB.execute("insert into text (id, text, source, disabled) values (?, ?, ?, ?)", (txt_id, x, id, dis))
except Exception:
pass # silently skip ...
r.append(txt_id)
if update:
self.update()
if lesson:
DB.commit()
return r
示例5: addTexts
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def addTexts(self, source, texts, lesson=None, update=True):
id = DB.getSource(source, lesson)
r = []
for x in texts:
h = hashlib.sha1()
h.update(x.encode("utf-8"))
txt_id = h.hexdigest()
dis = 1 if lesson == 2 else None
try:
DB.execute(
"insert into text (id,text,source,disabled) values (?,?,?,?)",
(txt_id, x, id, dis),
)
r.append(txt_id)
except Exception as e:
pass # silently skip ...
if update:
self.update()
if lesson:
DB.commit()
return r
示例6: removeDisabled
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
def removeDisabled(self):
DB.execute("delete from text where disabled is not null")
self.removeUnused()
self.update()
DB.commit()
示例7: sizeHint
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import commit [as 别名]
tm.nextText()
def sizeHint(self):
return QSize(650, 400)
class AboutWidget(QTextBrowser):
def __init__(self, *args):
html = "about.html file missing!"
try:
html = open("about.html", "r").read()
except:
pass
super(AboutWidget, self).__init__(*args)
self.setHtml(html)
self.setOpenExternalLinks(True)
#self.setMargin(40)
self.setReadOnly(True)
app = QApplication(sys.argv)
w = TyperWindow()
w.show()
app.exec_()
print "exit"
DB.commit()