commentDB.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:hearthscan-bot 作者: d-schmidt 项目源码 文件源码
def exists(self, submission_id, cards):
        """Test if request is a duplicate and inserts new
        :return: true if all cards are already posted for parent
        """
        query = ('SELECT card FROM topcomment '
                    ' WHERE submission_id = ?'
                    ' AND card IN (%s)' % ','.join('?' * len(cards)))
        params = list(itertools.chain((submission_id,), cards))

        foundCards = [row[0] for row in self.conn.execute(query, params)]
        inserted = False

        for card in cards:
            if card not in foundCards:
                inserted = True
                self.conn.execute("INSERT INTO topcomment (submission_id, card) VALUES (?, ?)",
                    (submission_id, card))

        self.conn.commit()

        return not inserted
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号