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


Python DBManager.create_session_scope_nc方法代码示例

本文整理汇总了Python中pajbot.managers.db.DBManager.create_session_scope_nc方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.create_session_scope_nc方法的具体用法?Python DBManager.create_session_scope_nc怎么用?Python DBManager.create_session_scope_nc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pajbot.managers.db.DBManager的用法示例。


在下文中一共展示了DBManager.create_session_scope_nc方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_deck

# 需要导入模块: from pajbot.managers.db import DBManager [as 别名]
# 或者: from pajbot.managers.db.DBManager import create_session_scope_nc [as 别名]
    def remove_deck(self, deck):
        self.data.remove(deck)
        with DBManager.create_session_scope_nc(expire_on_commit=False) as db_session:
            db_session.delete(deck)
            db_session.commit()

        if deck == self.current_deck:
            log.info('refreshing current deck')
            self.refresh_current_deck()
开发者ID:Nacht123,项目名称:pajbot,代码行数:11,代码来源:deck.py

示例2: reload

# 需要导入模块: from pajbot.managers.db import DBManager [as 别名]
# 或者: from pajbot.managers.db.DBManager import create_session_scope_nc [as 别名]
    def reload(self):
        self.data = []
        with DBManager.create_session_scope_nc(expire_on_commit=False) as db_session:
            for deck in db_session.query(Deck).order_by(Deck.last_used.desc()):
                if self.current_deck is None:
                    self.current_deck = deck
                self.data.append(deck)
                db_session.expunge(deck)

            db_session.expunge_all()
开发者ID:Nacht123,项目名称:pajbot,代码行数:12,代码来源:deck.py

示例3: set_current_deck

# 需要导入模块: from pajbot.managers.db import DBManager [as 别名]
# 或者: from pajbot.managers.db.DBManager import create_session_scope_nc [as 别名]
    def set_current_deck(self, deck_link):
        # Loop through our already loaded decks
        for deck in self.data:
            # Is this deck link already i use?
            if deck_link == deck.link:
                self.current_deck = deck
                self.update_deck(deck,
                        times_used=deck.times_used + 1,
                        last_used=datetime.datetime.now())
                return deck, False

        # No old deck matched the link, create a new deck!
        with DBManager.create_session_scope_nc(expire_on_commit=False) as db_session:
            deck = Deck()
            deck.set(link=deck_link,
                    times_used=1,
                    first_used=datetime.datetime.now(),
                    last_used=datetime.datetime.now())
            self.current_deck = deck
            self.data.append(deck)
            db_session.add(deck)
            db_session.commit()
            db_session.expunge(deck)
        return deck, True
开发者ID:Nacht123,项目名称:pajbot,代码行数:26,代码来源:deck.py

示例4: update_deck

# 需要导入模块: from pajbot.managers.db import DBManager [as 别名]
# 或者: from pajbot.managers.db.DBManager import create_session_scope_nc [as 别名]
 def update_deck(self, deck, **options):
     with DBManager.create_session_scope_nc(expire_on_commit=False) as db_session:
         db_session.add(deck)
         deck.set(**options)
         db_session.commit()
         db_session.expunge(deck)
开发者ID:Nacht123,项目名称:pajbot,代码行数:8,代码来源:deck.py


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