当前位置: 首页>>代码示例>>Python>>正文


Python DB.commit方法代码示例

本文整理汇总了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()
开发者ID:fredizzimo,项目名称:amphetype,代码行数:9,代码来源:TextManager.py

示例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()
开发者ID:maxme,项目名称:amphetype,代码行数:30,代码来源:Database.py

示例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()
开发者ID:gordonfierce,项目名称:amphetype,代码行数:15,代码来源:TextManager.py

示例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
开发者ID:maxme,项目名称:amphetype,代码行数:22,代码来源:TextManager.py

示例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
开发者ID:gordonfierce,项目名称:amphetype,代码行数:23,代码来源:TextManager.py

示例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()
开发者ID:gordonfierce,项目名称:amphetype,代码行数:7,代码来源:TextManager.py

示例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()


开发者ID:Alok,项目名称:amphetype,代码行数:29,代码来源:Amphetype.py


注:本文中的Data.DB.commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。