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


Python adbapi.safe函数代码示例

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


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

示例1: changePassword

 def changePassword(self, identityName, hashedPassword, callback=None, errback=None):
     passwd = base64.encodestring(hashedPassword)
     sql = """UPDATE twisted_identities
              SET password = '%s'
              WHERE identity_name = '%s'""" %\
                (adbapi.safe(passwd), adbapi.safe(identityName) )
     return self.runOperation(sql).addCallbacks(callback, errback)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:dbcred.py

示例2: removeIdentity

 def removeIdentity(self, identityName):
     """Delete an identity
     """
     sql = """DELETE FROM twisted_identities WHERE identity_name = '%s';
              DELETE FROM twisted_perspectives WHERE identity_name = '%s'""" %\
                  (adbapi.safe(identityName), adbapi.safe(identityName) )
     return self.runOperation(sql)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:dbcred.py

示例3: articleRequest

    def articleRequest(self, group, index, id = None):
        if id is not None:
            sql = """
                SELECT postings.article_index, articles.message_id, articles.header, articles.body
                FROM groups,postings LEFT OUTER JOIN articles
                ON articles.message_id = '%s'
                WHERE groups.name = '%s'
                AND groups.group_id = postings.group_id
            """ % (adbapi.safe(id), adbapi.safe(group))
        else:
            sql = """ 
                SELECT postings.article_index, articles.message_id, articles.header, articles.body
                FROM groups,articles LEFT OUTER JOIN postings
                ON postings.article_id = articles.article_id
                WHERE postings.article_index = %d
                AND postings.group_id = groups.group_id
                AND groups.name = '%s'
            """ % (index, adbapi.safe(group))

        return self.dbpool.runQuery(sql).addCallback(
            lambda result: (
                result[0][0],
                result[0][1],
                StringIO.StringIO(result[0][2] + '\r\n' + result[0][3])
            )
        )
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:26,代码来源:database.py

示例4: get_member_tickets

    def get_member_tickets(self, callback, error_handler, cardno=None, studyno=None):
        if not self.event_id:
            return None

        cardno = adbapi.safe(str(cardno))
        event = adbapi.safe(str(self.event_id))

        if cardno:
            column = "Felt20"
            value = cardno
        elif studyno:
            column = "Felt11"
            value = studyno
        else:
            return

        query = (
            "SELECT "
            + "sfl.FUnique AS ticket_id, "
            + "sfl.VareNr AS eventno, "
            + "medlemp.felt20 AS cardno "
            + "FROM sfl, sfh, medlemp "
            + "WHERE sfh.Debitor = medlemp.felt00 "
            + "AND sfl.SFHUnique = sfh.FUnique "
            + "AND medlemp.{0} = '{1}' ".format(column, value)
            + "AND sfl.VareNr = '{0}' ".format(event)
        )
        q = self.winkas_db.runQuery(query, ())
        q.addCallbacks(callback, error_handler)
开发者ID:hundeboll,项目名称:ticket,代码行数:29,代码来源:db.py

示例5: removePerspective

 def removePerspective(self, identityName, perspectiveName, callback=None, errback=None):
     """Delete a perspective for an identity
     """
     sql = """DELETE FROM twisted_perspectives
              WHERE identity_name = '%s'
              AND perspective_name = '%s'""" %\
                (adbapi.safe(identityName), adbapi.safe(perspectiveName))
     return self.runOperation(sql).addCallbacks(callback, errback)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:8,代码来源:dbcred.py

示例6: addIdentity

 def addIdentity(self, identity):
     """Store an identity in the database.
     """
     passwd = base64.encodestring(identity.hashedPassword)
     username = identity.name
     createIdentity = "INSERT INTO twisted_identities VALUES ('%s', '%s')" % (adbapi.safe(username), adbapi.safe(passwd) )
     s = [createIdentity]
     for (svcname, pname) in identity.keyring.keys():
         # note, we don't actually know perspective type at this point...
         s.append("INSERT INTO twisted_perspectives VALUES ('%s', '%s', '%s', NULL)" %
                  (adbapi.safe(username), adbapi.safe(pname), adbapi.safe(svcname)) )
     sql = string.join(s, '; \n')
     return self.runOperation(sql)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:13,代码来源:dbcred.py

示例7: get_query

 def get_query(self, component):
     return ''' SELECT COUNT(*)
         FROM information_schema.SCHEMATA
         WHERE SCHEMA_NAME="%s"
     ''' % adbapi.safe(
         component.split(NAME_SPLITTER)[-1]
     )
开发者ID:cholden,项目名称:ZenPacks.zenoss.MySqlMonitor,代码行数:7,代码来源:dsplugins.py

示例8: escape_string

 def escape_string(self, text):
     """Escape a string for use in an SQL statement. The default
     implementation escapes ' with '' and \ with \\. Redefine this
     function in a subclass if your database server uses different
     escaping rules.
     """
     return adbapi.safe(text)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:sqlreflector.py

示例9: getPerspectives

 def getPerspectives(self, identity_name):
     """Get the perspectives for an identity. Used by the web admin interface.
     """
     sql="""SELECT identity_name, perspective_name, service_name
            FROM twisted_perspectives
            WHERE identity_name = '%s'""" % adbapi.safe(identity_name)
     return self.runQuery(sql)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:dbcred.py

示例10: articleExistsRequest

 def articleExistsRequest(self, id):
     sql = """
         SELECT COUNT(message_id) FROM articles
         WHERE message_id = '%s'
     """ % (adbapi.safe(id),)
     
     return self.dbpool.runQuery(sql).addCallback(
         lambda result: bool(result[0][0])
     )
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:9,代码来源:database.py

示例11: get_member_used

    def get_member_used(self, callback, error_handler, cardno=None, studyno=None):
        if not self.event_id:
            return None

        cardno = adbapi.safe(str(cardno))
        event = adbapi.safe(str(self.event_id))

        if cardno:
            column = "cardno"
            value = cardno
        elif studyno:
            column = "studyno"
            value = studyno
        else:
            return

        query = "SELECT 1 FROM used WHERE `{0}` = '{1}' AND `eventno` = '{2}'".format(column, value, event)
        q = self.ticket_db.runQuery(query, ())
        q.addCallbacks(callback, error_handler)
开发者ID:hundeboll,项目名称:ticket,代码行数:19,代码来源:db.py

示例12: listGroupRequest

 def listGroupRequest(self, group):
     sql = """
         SELECT postings.article_index FROM postings,groups
         WHERE postings.group_id = groups.group_id
         AND groups.name = '%s'
     """ % (adbapi.safe(group),)
     
     return self.dbpool.runQuery(sql).addCallback(
         lambda results, group = group: (group, [res[0] for res in results])
     )
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:10,代码来源:database.py

示例13: headRequest

 def headRequest(self, group, index):
     sql = """
         SELECT postings.article_index, articles.message_id, articles.header
         FROM groups,articles LEFT OUTER JOIN postings
         ON postings.article_id = articles.article_id
         WHERE postings.article_index = %d
         AND postings.group_id = groups.group_id
         AND groups.name = '%s'
     """ % (index, adbapi.safe(group))
     
     return self.dbpool.runQuery(sql).addCallback(lambda result: result[0])
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:11,代码来源:database.py

示例14: getIdentityRequest

 def getIdentityRequest(self, name):
     """get the identity from the database with the specified name.
     """
     sql = """
     SELECT   twisted_identities.identity_name,
              twisted_identities.password,
              twisted_perspectives.perspective_name,
              twisted_perspectives.service_name
     FROM     twisted_identities,
              twisted_perspectives
     WHERE    twisted_identities.identity_name = twisted_perspectives.identity_name
     AND      twisted_identities.identity_name = '%s'
     """ % adbapi.safe(name)
     return self.runQuery(sql).addCallbacks(self._cbIdentity)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:14,代码来源:dbcred.py

示例15: xhdrRequest

    def xhdrRequest(self, group, low, high, header):
        sql = """
            SELECT articles.header
            FROM groups,postings,articles
            WHERE groups.name = '%s' AND postings.group_id = groups.group_id
            AND postings.article_index >= %d
            AND postings.article_index <= %d
        """ % (adbapi.safe(group), low, high)

        return self.dbpool.runQuery(sql).addCallback(
            lambda results: [
                (i, Article(h, None).getHeader(h)) for (i, h) in results
            ]
        )
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:14,代码来源:database.py


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