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


Python Database.query方法代码示例

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


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

示例1: decrease_order

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [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)
开发者ID:skarphed,项目名称:skarphed,代码行数:35,代码来源:action.py

示例2: delete

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete(self):
     """
     deletes this session
     """
     db = Database()
     stmnt = "DELETE FROM SESSIONS WHERE SES_ID = ? ;"
     db.query(stmnt,(self._id,),commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:9,代码来源:session.py

示例3: assign_to

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
    def assign_to(self,user):
        """
        Assigns this role to a user
        """
        session_user = Session.get_current_session_user()

        db = Database()
        
        #check if sessionuser has role
        
        has_role = session_user.has_role(self)

        stmnt = "SELECT COUNT(URI_RIG_ID) AS CNT FROM USERRIGHTS WHERE URI_RIG_ID IN \
            (SELECT RRI_RIG_ID FROM ROLERIGHTS WHERE RRI_ROL_ID = ? ) ;"
        cur = db.query(stmnt,(self._id,))
        res = cur.fetchone()[0]

        has_all_permissions_of_role = res == len(self.get_permissions())

        if not has_role and not has_all_permissions_of_role:
            raise PermissionException(PermissionException.get_msg(7))

        for role in user.get_grantable_roles():
            if role["name"] == self._name:
                stmnt = "UPDATE OR INSERT INTO USERROLES (URO_USR_ID, URO_ROL_ID) \
                    VALUES (?,?) MATCHING (URO_USR_ID, URO_ROL_ID) ;";
                db.query(stmnt, (user.get_id(),self._id),commit=True)
                PokeManager.add_activity(ActivityType.USER)
                return
        raise PermissionException(PermissionException.get_msg(8))
开发者ID:skarphed,项目名称:skarphed,代码行数:32,代码来源:permissions.py

示例4: move_to_bottom_order

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [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)
开发者ID:skarphed,项目名称:skarphed,代码行数:35,代码来源:action.py

示例5: delete

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete(self):
     """
     Deletes this Action from the database
     """
     db = Database()
     stmnt = "DELETE FROM ACTIONS WHERE ACT_ID = ? ;"
     db.query(stmnt, (self.get_id(),),commit=True)
     PokeManager.add_activity(ActivityType.MENU)
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:action.py

示例6: cleanup_css_sessiontable

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def cleanup_css_sessiontable(cls):
     """
     Cleans up old css filenames
     """
     db = Database()
     stmnt = "DELETE FROM CSSSESSION WHERE CSE_OUTDATED = 1 ;"
     db.query(stmnt, commit=True)
     return
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:css.py

示例7: remove_permissions_for_module

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def remove_permissions_for_module(cls,module):
     """
     removes the permissions of a module
     """
     module_name = module.get_name()
     db = Database()
     stmnt = "DELETE FROM RIGHTS WHERE RIG_NAME LIKE ? ;"
     db.query(stmnt, (module_name+"%",),commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:permissions.py

示例8: store

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def store(self):
     """
     currently only one repository can be owned by one skarphed instance
     """
     db = Database()
     stmnt = "UPDATE OR INSERT INTO REPOSITORIES (REP_ID, REP_NAME, REP_IP, REP_PORT, REP_LASTUPDATE, REP_PUBLICKEY) VALUES (1,?,?,?,?,?) MATCHING (REP_ID) ;"
     db.query(stmnt,(self._name, self._ip, self._port, self._lastupdate, self.get_public_key()),commit=True)
     PokeManager.add_activity(ActivityType.REPOSITORY)
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:module.py

示例9: remove_permission

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def remove_permission(cls, permission, module=""):
     """
     removes a permission from the database
     """
     db = Database()
     stmnt = "DELETE FROM RIGHTS WHERE RIG_NAME = ? ;"
     db.query(stmnt, (permission,),commit=True)
     PokeManager.add_activity(ActivityType.PERMISSION)
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:permissions.py

示例10: delete

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete(self):
     """
     deletes this role from the database
     """
     db = Database()
     stmnt = "DELETE FROM ROLES WHERE ROL_ID = ? ;"
     db.query(stmnt,(self._id,),commit=True)
     PokeManager.add_activity(ActivityType.ROLE)
开发者ID:skarphed,项目名称:skarphed,代码行数:10,代码来源:permissions.py

示例11: delete_actions_with_module

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete_actions_with_module(cls, module):
     """
     Deletes all actions that contain this widget
     """
     db = Database()
     stmnt = "DELETE FROM ACTIONS WHERE ACT_WGT_ID IN (SELECT WGT_ID FROM WIDGETS WHERE WGT_MOD_ID = ?) ;"
     db.query(stmnt,(module.get_id(),),commit=True)
     PokeManager.add_activity(ActivityType.MENU)
     return
开发者ID:skarphed,项目名称:skarphed,代码行数:11,代码来源:action.py

示例12: delete_actions_with_widget

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete_actions_with_widget(cls, widget):
     """
     Deletes all actions that contain this widget
     """
     db = Database()
     stmnt = "DELETE FROM ACTIONS WHERE ACT_WGT_ID = ? ;"
     db.query(stmnt,(widget.get_id(),),commit=True)
     PokeManager.add_activity(ActivityType.MENU)
     return
开发者ID:skarphed,项目名称:skarphed,代码行数:11,代码来源:action.py

示例13: delete_definitions_with_widget

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def delete_definitions_with_widget(cls, widget):
     """
     Deletes all Definitions that concern the given widget
     """
     db = Database()
     stmnt = "DELETE FROM CSS WHERE CSS_WGT_ID = ? ;"
     db.query(stmnt, (widget.get_id(),), commit=True)
     cls.cleanup_css_sessiontable()
     return
开发者ID:skarphed,项目名称:skarphed,代码行数:11,代码来源:css.py

示例14: set_name

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def set_name(self,name,ignore_db = True):
     """
     Sets the Name of the action
     """
     self._name = unicode(name)
     if not ignore_db:
         db = Database()
         stmnt = "UPDATE ACTIONS SET ACT_NAME = ? WHERE ACT_ID = ? ;"
         db.query(stmnt, (self._name, self.get_id()),commit=True)
开发者ID:skarphed,项目名称:skarphed,代码行数:11,代码来源:action.py

示例15: create_permission

# 需要导入模块: from skarphedcore.database import Database [as 别名]
# 或者: from skarphedcore.database.Database import query [as 别名]
 def create_permission(cls, permission, module=""):
     """
     Creates a new permission in database
     """
     db = Database()
     new_id = db.get_seq_next('RIG_GEN')
     stmnt = "INSERT INTO RIGHTS (RIG_ID, RIG_NAME) VALUES (?,?) ;"
     db.query(stmnt,(new_id,module+"."+permission),commit=True)
     PokeManager.add_activity(ActivityType.PERMISSION)
     return module+"."+permission
开发者ID:skarphed,项目名称:skarphed,代码行数:12,代码来源:permissions.py


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