本文整理汇总了Python中skarphedcore.database.Database.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Database.commit方法的具体用法?Python Database.commit怎么用?Python Database.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skarphedcore.database.Database
的用法示例。
在下文中一共展示了Database.commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: move_to_bottom_order
# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import commit [as 别名]
def move_to_bottom_order(self):
"""
Moves this menuitem to the bottom-order
"""
db = Database()
if self.get_menu_id() is not None:
stmnt = "SELECT MIN(MNI_ORDER) AS NEWORDER FROM MENUITEMS WHERE MNI_MNU_ID = ? ;"
cur = db.query(stmnt, (self.get_menu_id(),))
row = cur.fetchonemap()
if row is not None:
if row["NEWORDER"] is None:
return
temp_order = self.get_order()
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ORDER = ? AND MNI_MNU_ID = ? ;"
db.query(stmnt, (temp_order, row["NEWORDER"], self.get_menu_id()),commit=True)
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ID = ? ;"
db.query(stmnt, (row["NEWORDER"], self.get_id()),commit=True)
db.commit()
PokeManager.add_activity(ActivityType.MENU)
elif self.get_parent_menu_item_id() is not None:
stmnt = "SELECT MIN(MNI_ORDER) AS NEWORDER, MNI_ID FROM MENUITEMS WHERE MNI_MNI_ID = ? ;"
cur = db.query(stmnt, (self.get_parent_menu_item_id(),))
row = cur.fetchonemap()
if row is not None:
if row["NEWORDER"] is None:
return
temp_order = self.get_order()
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ORDER = ? AND MNI_MNI_ID = ? ;"
db.query(stmnt, (temp_order, row["NEWORDER"], self.get_parent_menu_item_id()),commit=True)
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ID = ? ;"
db.query(stmnt, (row["NEWORDER"], self.get_id()),commit=True)
db.commit()
PokeManager.add_activity(ActivityType.MENU)
示例2: decrease_order
# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import commit [as 别名]
def decrease_order(self):
"""
Decreases the order of this MenuItem
"""
db = Database()
if self.get_menu_id() is not None:
stmnt = "SELECT MAX(MNI_ORDER) AS NEWORDER FROM MENUITEMS WHERE MNI_MNU_ID = ? AND MNI_ORDER < ? ;"
cur = db.query(stmnt, (self.get_menu_id(), self.get_order()))
row = cur.fetchonemap()
if row is not None:
if row["NEWORDER"] is None:
return
temp_order = self.get_order()
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ORDER = ? AND MNI_MNU_ID = ? ;"
db.query(stmnt, (temp_order, row["NEWORDER"], self.get_menu_id()),commit=True)
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ID = ? ;"
db.query(stmnt, (row["NEWORDER"], self.get_id()),commit=True)
db.commit()
PokeManager.add_activity(ActivityType.MENU)
elif self.get_parent_menu_item_id() is not None:
stmnt = "SELECT MAX(MNI_ORDER) AS NEWORDER FROM MENUITEMS WHERE MNI_MNI_ID = ? AND MNI_ORDER < ? ;"
cur = db.query(stmnt, (self.get_parent_menu_item_id(), self.get_order()))
row = cur.fetchonemap()
if row is not None:
if row["NEWORDER"] is None:
return
temp_order = self.get_order()
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ORDER = ? AND MNI_MNI_ID = ? ;"
db.query(stmnt, (temp_order, row["NEWORDER"], self.get_parent_menu_item_id()),commit=True)
stmnt = "UPDATE MENUITEMS SET MNI_ORDER = ? WHERE MNI_ID = ? ;"
db.query(stmnt, (row["NEWORDER"], self.get_id()),commit=True)
db.commit()
PokeManager.add_activity(ActivityType.MENU)
示例3: delete
# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import commit [as 别名]
def delete(self):
"""
Deletes this menu from the database
"""
db = Database()
stmnt = "DELETE FROM MENUS WHERE MNU_ID = ? ;"
db.query(stmnt, (self.get_id(),),commit=True)
db.commit()
PokeManager.add_activity(ActivityType.MENU)
示例4: create_menu_item
# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import commit [as 别名]
def create_menu_item(cls, menu=None, menu_item_parent=None, name="new item"):
"""
This function creates a new MenuItem based on either:
1. A parent Menu or
2. A parent MenuItem
If none of those is set, the function will abort and return null
The MenuItem will be spawned with the lowest display order
"""
if menu is None and menu_item_parent is None:
return None
db = Database()
menu_item = MenuItem()
menu_item.set_name(name)
if menu is not None:
menu_item.set_menu_id(menu.get_id())
stmnt = "SELECT MAX(MNI_ORDER) AS MAXORDER FROM MENUITEMS WHERE MNI_MNU_ID = ? ;"
cur = db.query(stmnt, (menu.get_id(),))
if menu_item_parent is not None:
menu_item.set_parent_menu_item_id(menu_item_parent.get_id())
stmnt = "SELECT MAX(MNI_ORDER) AS MAXORDER FROM MENUITEMS WHERE MNI_MNI_ID = ? ;"
cur = db.query(stmnt, (menu_item_parent.get_id(),))
menu_item.set_id(db.get_seq_next('MNI_GEN'))
row = cur.fetchonemap()
if row["MAXORDER"] is not None:
new_order = row["MAXORDER"]+1
else:
new_order = 0
menu_item.set_order(new_order)
stmnt = "INSERT INTO MENUITEMS VALUES (?,?,?,?,?,?) ;"
db.query(stmnt,(menu_item.get_id(), menu_item.get_name(),
menu_item.get_menu_id(), menu_item.get_parent_menu_item_id(),
None, menu_item.get_order()),commit=True)
db.commit()
action_list = ActionList.create_action_list()
menu_item.assign_action_list(action_list)
PokeManager.add_activity(ActivityType.MENU)
return menu_item