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


Python rhnSQL.execute函数代码示例

本文整理汇总了Python中spacewalk.server.rhnSQL.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: updateDist

    def updateDist(self, kwargs, username, password):
        log_debug(3)
        self._auth(username, password)
        
        if not kwargs.get('release'):
            raise rhnFault(23, "Insufficient data, release missing to update dist", explain=0)
                     
        if not kwargs.get('os'):
            kwargs['os'] = 'Red Hat Linux'

        if kwargs.get('channel_id') is None:
            # Missing stuff
            raise rhnFault(23, "Insufficient data, channel_id missing to update dist", explain=0)

        if kwargs.get('channel_arch_id') is None:
            # Missing stuff
            raise rhnFault(23, "Insufficient data, channel arch id missing to update dist", explain=0)
            
        try:
            rhnSQL.execute("""
            insert into rhnDistChannelMap 
                (channel_id, channel_arch_id, os, release)
            values
                (:channel_id, :channel_arch_id, :os, :release)
            """, kwargs)
        except rhnSQL.SQLError, e:
            rhnSQL.rollback()
            raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:28,代码来源:channel.py

示例2: moveChannelDownloads

 def moveChannelDownloads(self, channel_id, old_channel_family_id,
                            new_channel_family_id, username, password):
     log_debug(3)
     self._auth(username, password)
     
     if old_channel_family_id is None or \
            old_channel_family_id == new_channel_family_id:
         # Nothing to be done here, same channel family
         return 0
     log_debug(3, "  Migrating downloads")
     
     try:
         rhnSQL.execute("""
         update rhnDownloads
            set channel_family_id = :new_channel_family_id
          where channel_family_id = :old_channel_family_id
            and id in (
                select downloads_id
                  from rhnChannelDownloads
                 where channel_id = :channel_id)
             """,
             channel_id=channel_id,
             old_channel_family_id=old_channel_family_id,
             new_channel_family_id=new_channel_family_id,
             )
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:28,代码来源:channel.py

示例3: _channelPermission

 def _channelPermission(self, label, role, commit, username, password, query):
     log_debug(3)
     self._auth(username, password)
     try:
         rhnSQL.execute(query, username = username, label = label, role_label = role)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:channel.py

示例4: setUp

    def setUp(self):
        self.table_name = "misatest_%d" % os.getpid()
        rhnSQL.initDB(DB)
        self._cleanup()

        rhnSQL.execute("create table %s (id int, val varchar2(10))" %
            self.table_name)
        rhnSQL.commit()
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:test_1.py

示例5: test_ddl_1

 def test_ddl_1(self):
     """Tests table creation/table removal"""
     table_name = self.table_name + "_1"
     rhnSQL.execute("create table %s (id int)" % table_name)
     tables = self._list_tables()
     self.failUnless(string.upper(table_name) in tables, 
         "Table %s not created" % table_name)
     rhnSQL.execute("drop table %s" % table_name)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:8,代码来源:test_1.py

示例6: setUp

    def setUp(self):
        rhnSQL.initDB(
            backend="oracle",
            username=DB_SETTINGS["user"],
            password=DB_SETTINGS["password"],
            database=DB_SETTINGS["database"]
        )
        self._cleanup()

        rhnSQL.execute("create table misatestlob (id int, val blob)")
        rhnSQL.execute("create sequence misatestlob_id_seq")
开发者ID:TJM,项目名称:spacewalk,代码行数:11,代码来源:test_lob.py

示例7: deleteDist

 def deleteDist(self, channel_id, username, password):
     log_debug(3)
     self._auth(username, password)
     
     try:
         rhnSQL.execute("""
         delete from rhnDistChannelMap where channel_id = :channel_id
         """, channel_id=channel_id)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:11,代码来源:channel.py

示例8: _cleanup

    def _cleanup(self):
        try:
            rhnSQL.execute("drop table misatestlob")
        except rhnSQL.SQLStatementPrepareError:
            pass

        try:
            rhnSQL.execute("drop sequence misatestlob_id_seq")
        except rhnSQL.SQLStatementPrepareError:
            pass
        except rhnSQL.SQLError, e:
            if e.args[0] != 2289:
                raise
开发者ID:TJM,项目名称:spacewalk,代码行数:13,代码来源:test_lob.py

示例9: setUp

    def setUp(self):
        self.table_name = "misatest_%d" % os.getpid()
        rhnSQL.initDB(
            backend="oracle",
            username=DB_SETTINGS["user"],
            password=DB_SETTINGS["password"],
            database=DB_SETTINGS["database"]
        )
        self._cleanup()

        rhnSQL.execute("create table %s (id int, val varchar2(10))" %
                       self.table_name)
        rhnSQL.commit()
开发者ID:m47ik,项目名称:uyuni,代码行数:13,代码来源:test_1.py

示例10: test_execute_rowcount

    def test_execute_rowcount(self):
        """Tests row counts"""
        # XXX
        table_name = "misatest"
        rhnSQL.execute("delete from misatest")
        ret = rhnSQL.execute("insert into misatest values (1, 1)")
        self.assertEqual(ret, 1)
        ret = rhnSQL.execute("insert into misatest values (2, 2)")
        self.assertEqual(ret, 1)

        ret = rhnSQL.execute("delete from misatest")
        self.assertEqual(ret, 2)
        rhnSQL.commit()
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:13,代码来源:test_1.py

示例11: management_disable_file

    def management_disable_file(self, dict):
        log_debug(1)
        self._get_and_validate_session(dict)

        config_channel = dict.get("config_channel")
        # XXX Validate the namespace
        path = dict.get("path")

        t = rhnSQL.Table("rhnConfigFileState", "label")
        state_id_dead = t["dead"]["id"]

        row = rhnSQL.fetchone_dict(self._query_lookup_config_file_by_channel, config_channel=config_channel, path=path)
        if not row or row["state_id"] == state_id_dead:
            raise rhnFault(4011, "File %s does not exist in channel %s" % (path, config_channel), explain=0)

        rhnSQL.execute(self._query_update_file_state, config_file_id=row["id"], state_id=state_id_dead)
        rhnSQL.commit()
        return {}
开发者ID:pombredanne,项目名称:spacewalk-2,代码行数:18,代码来源:rhn_config_management.py

示例12: updateChannelMembership

    def updateChannelMembership(self, channel_id, channel_family_id,
                                kargs, commit, username, password):
        log_debug(3)
        authobj = self._auth(username, password)
        authobj.isChannelAdmin()

        rhnSQL.execute("""
            delete from rhnChannelFamilyMembers where channel_id = :channel_id""",
            channel_id=channel_id)
        
        try:
            rhnSQL.execute("""
            insert into rhnChannelFamilyMembers (channel_id, channel_family_id )
            values (:channel_id, :channel_family_id)
            """, channel_id=channel_id, channel_family_id=channel_family_id)
        except rhnSQL.SQLError, e:
            rhnSQL.rollback()
            raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:18,代码来源:channel.py

示例13: createChannel

 def createChannel(self, params, commit, username, password):       
     log_debug(3)
     self._auth(username, password)
     
     params['id'] = rhnSQL.Sequence("rhn_channel_id_seq").next()
     fields = []
     for f in rhnChannel_fields:
         if params.has_key(f):
             fields.append(f)
     
     field_names = string.join(fields, ", ")
     bind_vars = string.join(map(lambda x: ':' + x, fields), ', ')
     try:
         rhnSQL.execute("insert into rhnChannel (%s) values (%s)" %
                              (field_names, bind_vars),
                              **params)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:19,代码来源:channel.py

示例14: test_execute_rowcount

    def test_execute_rowcount(self):
        """Tests row counts"""
        table_name = "misatest"
        try:
            tables = self._list_tables()
            if not table_name in tables:
                rhnSQL.execute("create table %s (id int, value int)" % table_name)
            else:
                rhnSQL.execute("delete from %s" % table_name)

            insert_statement = rhnSQL.Statement(
                "insert into %s values (:item_id, :value)" % table_name
            )
            h = rhnSQL.prepare(insert_statement)
            ret = h.execute(item_id=1, value=2)
            self.assertEqual(ret, 1)
            ret = h.execute(item_id=2, value=2)
            self.assertEqual(ret, 1)

            delete_statement = rhnSQL.Statement("delete from %s" % table_name)
            h = rhnSQL.prepare(delete_statement)
            ret = h.execute()
            self.assertEqual(ret, 2)
            rhnSQL.commit()
        finally:
            rhnSQL.execute("drop table %s" % table_name)
开发者ID:flavio,项目名称:spacewalk,代码行数:26,代码来源:test_1.py

示例15: updateChannel

 def updateChannel(self, params, channel_id, old_channel_family_id,
                   new_channel_family_id, commit, username, password):
     log_debug(3)
     global rhnChannel_fields
     
     authobj = self._auth(username, password)
     authobj.isChannelAdmin()
     
     fields = []
     for f in rhnChannel_fields:
         if params.has_key(f):
             fields.append(f)
     
     set_clause = string.join(
         map(lambda x: "%s = :%s" % (x, x), fields), ', ')
     
     try:
         rhnSQL.execute("update rhnChannel set %s where id = :id" % set_clause,
                        **params)
     except rhnSQL.SQLError, e:
         rhnSQL.rollback()
         raise rhnFault(23, str(e.args[1]), explain=0 )
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:22,代码来源:channel.py


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