本文整理汇总了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()
示例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()
示例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
示例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)