• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python MySQLdb.escape函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_where_clause

    def get_where_clause(self):

        if self.search_term[0] != "*":
            match_clause = """(MATCH (ProbeSet.Name,
                        ProbeSet.description,
                        ProbeSet.symbol,
                        alias,
                        GenbankId,
                        UniGeneId,
                        Probe_Target_Description)
                        AGAINST ('%s' IN BOOLEAN MODE)) and
                                """ % (
                escape(self.search_term[0])
            )
        else:
            match_clause = ""

        where_clause = (
            match_clause
            + """ProbeSet.Id = ProbeSetXRef.ProbeSetId
               and ProbeSetXRef.ProbeSetFreezeId = %s
                        """
            % (escape(str(self.dataset.id)))
        )

        return where_clause
开发者ID:DannyArends,项目名称:genenetwork2,代码行数:26,代码来源:do_search.py


示例2: convert_to_mouse_gene_id

    def convert_to_mouse_gene_id(self, species=None, gene_id=None):
        """If the species is rat or human, translate the gene_id to the mouse geneid

        If there is no input gene_id or there's no corresponding mouse gene_id, return None

        """
        if not gene_id:
            return None

        mouse_gene_id = None

        if species == 'mouse':
            mouse_gene_id = gene_id

        elif species == 'rat':

            query = """SELECT mouse
                   FROM GeneIDXRef
                   WHERE rat='%s'""" % escape(gene_id)

            result = g.db.execute(query).fetchone()
            if result != None:
                mouse_gene_id = result.mouse

        elif species == 'human':

            query = """SELECT mouse
                   FROM GeneIDXRef
                   WHERE human='%s'""" % escape(gene_id)

            result = g.db.execute(query).fetchone()
            if result != None:
                mouse_gene_id = result.mouse

        return mouse_gene_id
开发者ID:genenetwork,项目名称:genenetwork2,代码行数:35,代码来源:show_corr_results.py


示例3: do_lit_correlation_for_trait_list

    def do_lit_correlation_for_trait_list(self):

        input_trait_mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), self.this_trait.geneid)

        for trait in self.correlation_results:

            if trait.geneid:
                trait.mouse_gene_id = self.convert_to_mouse_gene_id(self.dataset.group.species.lower(), trait.geneid)
            else:
                trait.mouse_gene_id = None

            if trait.mouse_gene_id and str(trait.mouse_gene_id).find(";") == -1:
                result = g.db.execute(
                    """SELECT value
                       FROM LCorrRamin3
                       WHERE GeneId1='%s' and
                             GeneId2='%s'
                    """ % (escape(str(trait.mouse_gene_id)), escape(str(input_trait_mouse_gene_id)))
                ).fetchone()
                if not result:
                    result = g.db.execute("""SELECT value
                       FROM LCorrRamin3
                       WHERE GeneId2='%s' and
                             GeneId1='%s'
                    """ % (escape(str(trait.mouse_gene_id)), escape(str(input_trait_mouse_gene_id)))
                    ).fetchone()

                if result:
                    lit_corr = result.value
                    trait.lit_corr = lit_corr
                else:
                    trait.lit_corr = 0
            else:
                trait.lit_corr = 0
开发者ID:genenetwork,项目名称:genenetwork2,代码行数:34,代码来源:show_corr_results.py


示例4: compile_final_query

    def compile_final_query(self, from_clause="", where_clause=""):
        """Generates the final query string"""

        from_clause = self.normalize_spaces(from_clause)

        if self.search_term[0] == "*":
            query = (
                self.base_query
                + """%s
                        WHERE PublishXRef.InbredSetId = %s
                        and PublishXRef.PhenotypeId = Phenotype.Id
                        and PublishXRef.PublicationId = Publication.Id
                        and PublishFreeze.Id = %s"""
                % (from_clause, escape(str(self.dataset.group.id)), escape(str(self.dataset.id)))
            )
        else:
            query = (
                self.base_query
                + """%s
                        WHERE %s
                        and PublishXRef.InbredSetId = %s
                        and PublishXRef.PhenotypeId = Phenotype.Id
                        and PublishXRef.PublicationId = Publication.Id
                        and PublishFreeze.Id = %s"""
                % (from_clause, where_clause, escape(str(self.dataset.group.id)), escape(str(self.dataset.id)))
            )

        return query
开发者ID:DannyArends,项目名称:genenetwork2,代码行数:28,代码来源:do_search.py


示例5: get_sequence

 def get_sequence(self):
     query = """
                 SELECT
                         ProbeSet.BlatSeq
                 FROM
                         ProbeSet, ProbeSetFreeze, ProbeSetXRef
                 WHERE
                         ProbeSet.Id=ProbeSetXRef.ProbeSetId and
                         ProbeSetFreeze.Id = ProbeSetXRef.ProbSetFreezeId and
                         ProbeSet.Name = %s
                         ProbeSetFreeze.Name = %s
             """ % (escape(self.name), escape(self.dataset.name))
     results = g.db.execute(query).fetchone()
     return results[0]
开发者ID:DannyArends,项目名称:genenetwork2_diet,代码行数:14,代码来源:data_set.py


示例6: retrieve_other_names

    def retrieve_other_names(self):
        """This method fetches the the dataset names in search_result.

        If the data set name parameter is not found in the 'Name' field of
        the data set table, check if it is actually the FullName or
        ShortName instead.

        This is not meant to retrieve the data set info if no name at
        all is passed.

        """


        try:
            if self.type == "ProbeSet":
                query_args = tuple(escape(x) for x in (
                    str(webqtlConfig.PUBLICTHRESH),
                    self.name,
                    self.name,
                    self.name))

                self.id, self.name, self.fullname, self.shortname, self.data_scale, self.tissue = fetch1("""
SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, ProbeSetFreeze.DataScale, Tissue.Name
FROM ProbeSetFreeze, ProbeFreeze, Tissue
WHERE ProbeSetFreeze.public > %s
AND ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id
AND ProbeFreeze.TissueId = Tissue.Id
AND (ProbeSetFreeze.Name = '%s' OR ProbeSetFreeze.FullName = '%s' OR ProbeSetFreeze.ShortName = '%s')
                """ % (query_args),"/dataset/"+self.name+".json",
            lambda r: (r["id"],r["name"],r["full_name"],r["short_name"],r["data_scale"],r["tissue"])
                )
            else:
                query_args = tuple(escape(x) for x in (
                    (self.type + "Freeze"),
                    str(webqtlConfig.PUBLICTHRESH),
                    self.name,
                    self.name,
                    self.name))

                self.tissue = "N/A"
                self.id, self.name, self.fullname, self.shortname = fetchone("""
                        SELECT Id, Name, FullName, ShortName
                        FROM %s
                        WHERE public > %s AND
                             (Name = '%s' OR FullName = '%s' OR ShortName = '%s')
                  """ % (query_args))

        except TypeError:
            logger.debug("Dataset {} is not yet available in GeneNetwork.".format(self.name))
            pass
开发者ID:zsloan,项目名称:genenetwork2,代码行数:50,代码来源:data_set.py


示例7: compile_final_query

    def compile_final_query(self, from_clause = '', where_clause = ''):
        """Generates the final query string"""

        from_clause = self.normalize_spaces(from_clause)

        query = (self.base_query +
            """%s
                WHERE %s
                    and ProbeSet.Id = ProbeSetXRef.ProbeSetId
                    and ProbeSetXRef.ProbeSetFreezeId = %s
                ORDER BY ProbeSet.symbol ASC
                            """ % (escape(from_clause),
                                    where_clause,
                                    escape(str(self.dataset.id))))
        return query
开发者ID:genenetwork,项目名称:genenetwork2,代码行数:15,代码来源:do_search.py


示例8: retrieve_other_names

    def retrieve_other_names(self):
        """
        If the data set name parameter is not found in the 'Name' field of the data set table,
        check if it is actually the FullName or ShortName instead.

        This is not meant to retrieve the data set info if no name at all is passed.

        """

        query_args = tuple(escape(x) for x in (
            (self.type + "Freeze"),
            str(webqtlConfig.PUBLICTHRESH),
            self.name,
            self.name,
            self.name))
        print("query_args are:", query_args)

        #print("""
        #        SELECT Id, Name, FullName, ShortName
        #        FROM %s
        #        WHERE public > %s AND
        #             (Name = '%s' OR FullName = '%s' OR ShortName = '%s')
        #  """ % (query_args))
        
        try:
            self.id, self.name, self.fullname, self.shortname = g.db.execute("""
                    SELECT Id, Name, FullName, ShortName
                    FROM %s
                    WHERE public > %s AND
                         (Name = '%s' OR FullName = '%s' OR ShortName = '%s')
              """ % (query_args)).fetchone()
        except TypeError:
            print("Dataset {} is not yet available in GeneNetwork.".format(self.name))
            pass
开发者ID:OriginalPenguin,项目名称:genenetwork,代码行数:34,代码来源:data_set.py


示例9: run

    def run(self):

        self.search_term = [float(value) for value in self.search_term]

        if self.search_operator == "=":
            assert isinstance(self.search_term, (list, tuple))
            self.range_min, self.range_max = self.search_term[:2]
            self.where_clause = """ (SELECT Pow(2, max(value) -min(value))
                                     FROM ProbeSetData
                                     WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s AND
                                    (SELECT Pow(2, max(value) -min(value))
                                     FROM ProbeSetData
                                     WHERE ProbeSetData.Id = ProbeSetXRef.dataId) < %s
                                    """ % self.mescape(min(self.range_min, self.range_max),
                                                       max(self.range_min, self.range_max))
        else:
            # Deal with >, <, >=, and <=
            self.where_clause = """ (SELECT Pow(2, max(value) -min(value))
                                     FROM ProbeSetData
                                     WHERE ProbeSetData.Id = ProbeSetXRef.dataId) > %s
                                    """ % (escape(self.search_term[0]))

        print("where_clause is:", pf(self.where_clause))

        self.query = self.compile_final_query(where_clause = self.where_clause)

        return self.execute(self.query)
开发者ID:OriginalPenguin,项目名称:genenetwork,代码行数:27,代码来源:do_search.py


示例10: setup

    def setup(self):
        # Fields in the database table
        self.search_fields = ['Name',
                              'Chr']

        # Find out what display_fields is
        self.display_fields = ['name',
                               'chr',
                               'mb',
                               'source2',
                               'sequence']

        # Fields displayed in the search results table header
        self.header_fields = ['Index',
                              'ID',
                              'Location']

        # Todo: Obsolete or rename this field
        self.type = 'Geno'

        self.query_for_group = '''
                SELECT
                        InbredSet.Name, InbredSet.Id, InbredSet.GeneticType
                FROM
                        InbredSet, GenoFreeze
                WHERE
                        GenoFreeze.InbredSetId = InbredSet.Id AND
                        GenoFreeze.Name = "%s"
                ''' % escape(self.name)
开发者ID:zsloan,项目名称:genenetwork2,代码行数:29,代码来源:data_set.py


示例11: build_table_dump

 def build_table_dump(table_name, rows_with_desc, ignore_duplicate_insert):
     "Build a dump-like output from the given table and rows"
     table_dump = ''
     for row in rows_with_desc[0]:
         table_dump += 'INSERT%s INTO %s VALUES (%s);\n' % \
                       (ignore_duplicate_insert and ' IGNORE' or '',
                        table_name,
                        ','.join([escape(column, conversions) for column in row]))
     return table_dump
开发者ID:aw-bib,项目名称:tind-invenio,代码行数:9,代码来源:websubmitadmincli.py


示例12: retrieve_other_names

    def retrieve_other_names(self):
        """
        If the data set name parameter is not found in the 'Name' field of the data set table,
        check if it is actually the FullName or ShortName instead.

        This is not meant to retrieve the data set info if no name at all is passed.

        """

        try:
            if self.type == "ProbeSet":
                query_args = tuple(escape(x) for x in (
                    str(webqtlConfig.PUBLICTHRESH),
                    self.name,
                    self.name,
                    self.name))

                self.id, self.name, self.fullname, self.shortname, self.tissue = g.db.execute("""
                        SELECT ProbeSetFreeze.Id, ProbeSetFreeze.Name, ProbeSetFreeze.FullName, ProbeSetFreeze.ShortName, Tissue.Name
                        FROM ProbeSetFreeze, ProbeFreeze, Tissue
                        WHERE ProbeSetFreeze.public > %s AND
                              ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND
                              ProbeFreeze.TissueId = Tissue.Id AND
                             (ProbeSetFreeze.Name = '%s' OR ProbeSetFreeze.FullName = '%s' OR ProbeSetFreeze.ShortName = '%s')
                  """ % (query_args)).fetchone()
            else:
                query_args = tuple(escape(x) for x in (
                    (self.type + "Freeze"),
                    str(webqtlConfig.PUBLICTHRESH),
                    self.name,
                    self.name,
                    self.name))

                self.tissue = "N/A"
                self.id, self.name, self.fullname, self.shortname = g.db.execute("""
                        SELECT Id, Name, FullName, ShortName
                        FROM %s
                        WHERE public > %s AND
                             (Name = '%s' OR FullName = '%s' OR ShortName = '%s')
                  """ % (query_args)).fetchone()

        except TypeError:
            print("Dataset {} is not yet available in GeneNetwork.".format(self.name))
            pass
开发者ID:DannyArends,项目名称:genenetwork2_diet,代码行数:44,代码来源:data_set.py


示例13: run_combined

    def run_combined(self, from_clause, where_clause):
        """Generates and runs a combined search of an phenotype dataset"""

        logger.debug("Running PhenotypeSearch")

        from_clause = self.normalize_spaces(from_clause)

        query = (
            self.base_query
            + """%s
                    WHERE %s
                    PublishXRef.InbredSetId = %s and
                    PublishXRef.PhenotypeId = Phenotype.Id and
                    PublishXRef.PublicationId = Publication.Id and
                    PublishFreeze.Id = %s"""
            % (from_clause, where_clause, escape(str(self.dataset.group.id)), escape(str(self.dataset.id)))
        )

        return self.execute(query)
开发者ID:DannyArends,项目名称:genenetwork2,代码行数:19,代码来源:do_search.py


示例14: retrieve_genes

    def retrieve_genes(self, column_name):
        query = """
                    select ProbeSet.Name, ProbeSet.%s
                    from ProbeSet,ProbeSetXRef
                    where ProbeSetXRef.ProbeSetFreezeId = %s and
                    ProbeSetXRef.ProbeSetId=ProbeSet.Id;
                """ % (column_name, escape(str(self.id)))
        results = g.db.execute(query).fetchall()

        return dict(results)
开发者ID:DannyArends,项目名称:genenetwork2_diet,代码行数:10,代码来源:data_set.py


示例15: run_combined

    def run_combined(self, from_clause = '', where_clause = ''):
        """Generates and runs a combined search of an mRNA expression dataset"""

        logger.debug("Running ProbeSetSearch")
        #query = self.base_query + from_clause + " WHERE " + where_clause

        from_clause = self.normalize_spaces(from_clause)

        query = (self.base_query +
            """%s
                WHERE %s
                    and ProbeSet.Id = ProbeSetXRef.ProbeSetId
                    and ProbeSetXRef.ProbeSetFreezeId = %s
                ORDER BY ProbeSet.symbol ASC
                            """ % (escape(from_clause),
                                    where_clause,
                                    escape(str(self.dataset.id))))

        return self.execute(query)
开发者ID:genenetwork,项目名称:genenetwork2,代码行数:19,代码来源:do_search.py


示例16: compile_final_query

    def compile_final_query(self, from_clause = '', where_clause = ''):
        """Generates the final query string"""

        from_clause = self.normalize_spaces(from_clause)

        query = (self.base_query +
                """%s
                    WHERE %s
                    PublishXRef.InbredSetId = %s and
                    PublishXRef.PhenotypeId = Phenotype.Id and
                    PublishXRef.PublicationId = Publication.Id and
                    PublishFreeze.Id = %s""" % (
                        from_clause,
                        where_clause,
                        escape(str(self.dataset.group.id)),
                        escape(str(self.dataset.id))))

        print("query is:", pf(query))

        return query
开发者ID:OriginalPenguin,项目名称:genenetwork,代码行数:20,代码来源:do_search.py


示例17: retrieve_sample_data

 def retrieve_sample_data(self, trait):
     query = """
                 SELECT
                         Strain.Name, ProbeSetData.value, ProbeSetSE.error, ProbeSetData.Id
                 FROM
                         (ProbeSetData, ProbeSetFreeze, Strain, ProbeSet, ProbeSetXRef)
                 left join ProbeSetSE on
                         (ProbeSetSE.DataId = ProbeSetData.Id AND ProbeSetSE.StrainId = ProbeSetData.StrainId)
                 WHERE
                         ProbeSet.Name = '%s' AND ProbeSetXRef.ProbeSetId = ProbeSet.Id AND
                         ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id AND
                         ProbeSetFreeze.Name = '%s' AND
                         ProbeSetXRef.DataId = ProbeSetData.Id AND
                         ProbeSetData.StrainId = Strain.Id
                 Order BY
                         Strain.Name
                 """ % (escape(trait), escape(self.name))
     results = g.db.execute(query).fetchall()
     #print("RETRIEVED RESULTS HERE:", results)
     return results
开发者ID:DannyArends,项目名称:genenetwork2_diet,代码行数:20,代码来源:data_set.py


示例18: get_trait_list

 def get_trait_list(self):
     query = """
         select Geno.Name
         from Geno, GenoXRef
         where GenoXRef.GenoId = Geno.Id
         and GenoFreezeId = {}
         """.format(escape(str(self.id)))
     results = g.db.execute(query).fetchall()
     trait_data = {}
     for trait in results:
         trait_data[trait[0]] = self.retrieve_sample_data(trait[0])
     return trait_data
开发者ID:DannyArends,项目名称:genenetwork2_diet,代码行数:12,代码来源:data_set.py


示例19: get_where_clause

    def get_where_clause(self):
        field = 'GOterm.acc'
        go_id = 'GO:' + ('0000000'+self.search_term[0])[-7:]

        statements = ("""%s.symbol=GOgene_product.symbol and
           GOassociation.gene_product_id=GOgene_product.id and
           GOterm.id=GOassociation.term_id""" % (
            escape(self.dataset.type)))

        where_clause = " %s = '%s' and %s " % (field, go_id, statements)

        return where_clause
开发者ID:genenetwork,项目名称:genenetwork2,代码行数:12,代码来源:do_search.py


示例20: run

    def run(self):
        """Generates and runs a search for assays across all mRNA expression datasets"""

        logger.debug("Running ProbeSetSearch")
        query = self.base_query + """WHERE (MATCH (ProbeSet.Name,
                    ProbeSet.description,
                    ProbeSet.symbol,
                    ProbeSet.alias)
                    AGAINST ('%s' IN BOOLEAN MODE))
                            """ % (escape(self.search_term[0]))

        return self.execute(query)
开发者ID:pjotrp,项目名称:genenetwork2,代码行数:12,代码来源:do_search.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python MySQLdb.escape_string函数代码示例发布时间:2022-05-24
下一篇:
Python MySQLdb.connect函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap