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


Python Connection.query方法代码示例

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


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

示例1: all

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import query [as 别名]
    def all(cls, schema, table):
        data = Connection.query(
            """ SELECT conname,
                pg_catalog.pg_get_constraintdef(r.oid, true) as condef
                FROM pg_catalog.pg_constraint r
                WHERE conrelid::regclass = (%s || '.' || %s)::regclass
                """,

            (schema, table,)
        )

        return [Constraint(name=reg[0], definition=reg[1]) for reg in data]
开发者ID:sigma-geosistemas,项目名称:docgen,代码行数:14,代码来源:models.py

示例2: with_name

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import query [as 别名]
    def with_name(cls, name):

        """ Retorna um objeto Schema referente ao schema com nome indicado.
            None caso não haja nenhum.
        """

        data = Connection.query(
            "SELECT nspname as name, "
            "pg_catalog.obj_description(ns.oid,'pg_namespace') as description "
            " FROM pg_catalog.pg_namespace ns  WHERE nspname = %s", (name,))

        if data:
            return Schema(name=data[0][0], description=data[0][1])
        else:
            return None
开发者ID:sigma-geosistemas,项目名称:docgen,代码行数:17,代码来源:models.py

示例3: implements

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import query [as 别名]
    def implements(self):
        """
        Inspects the wiki triples for "implements" links and returns them with their namespace removed.
        @return: the list of features
        @rtype list of str
        """
        if not '_Member__implements' in self.__dict__:
            self.__implements = []

            connection = Connection('http://triples.101companies.org/openrdf-sesame/')
            connection.use_repository('Testing_2')

            connection.addnamespace('onto', 'http://101companies.org/ontology#')
            connection.addnamespace('res', 'http://101companies.org/resources#')
            res = connection.query('SELECT DISTINCT ?feature WHERE { <http://101companies.org/resources#'+self.name+'> <http://101companies.org/ontology#implements> ?feature }')
            for feature in res:
                val = feature['feature']['value'].replace('http://101companies.org/resources#','').replace('_',' ')
                self.__implements.append(val)

        return self.__implements
开发者ID:101companies,项目名称:101worker,代码行数:22,代码来源:__init__.py

示例4: checkHirerarchy

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import query [as 别名]
    def checkHirerarchy():
        env = Environment(loader=FileSystemLoader('tmpl'))
        connection = Connection('http://triples.101companies.org:8080/openrdf-sesame/')
        connection.use_repository('sandbox')

        connection.addnamespace('onto', 'http://101companies.org/ontology#')
        connection.addnamespace('res', 'http://101companies.org/resources#')
        template = env.get_template('subtypeCheck')
        print "Subtyping check"
        query = template.render()
        res = connection.query(query)
        x = list()
        for r in res:
            print r
            if not r.has_key('c'):
                t = ("Base: " + r['a']['value'], "First Child: " + r['b']['value'])
            else:
                t = ("Base: " + r['a']['value'], "First Child: " + r['b']['value'], "Second Child: " + r['c']['value'])
            if not t in x:
                x.append(t)
        print x
        with open('subtyping_errors.json', 'w') as outfile:
            json.dump(x, outfile)
开发者ID:MartinFSchmitz,项目名称:101worker,代码行数:25,代码来源:model.py

示例5: __init__

# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import query [as 别名]
class Entity:
    def __init__(self, fn):
        json_data = open(fn)
        data = json.load(json_data)

        #self.context = data['@context']
        if 'properties' in data:
            self.properties = data['properties']
        else:
            self.properties = None

        self.id = data['@id']
        self.type = data['@type']

        self.env = Environment(loader=FileSystemLoader('tmpl'))
        self.connection = Connection('http://triples.101companies.org:8080/openrdf-sesame/')
        self.connection.use_repository('sandbox')

        self.connection.addnamespace('onto', 'http://101companies.org/ontology#')
        self.connection.addnamespace('res', 'http://101companies.org/resources#')

    def checkCardinality(self):
        template = self.env.get_template('cardinalityCheck')
        type = self.id

        if self.properties is None:
            return

        for prop in self.properties:
            p = prop['property']
            c = int(prop['minCardinality'])
            print "Cardinality check for class: %s and relationship: %s" % (type, p)
            query = template.render(ontoClass=type, relationship=p)
            res2 = self.connection.query(query)
            for r in res2:
                #print ">># of relationships declared: %s" % r['count']['value']
                if int(r['count']['value']) >= 0:
                    #print r
                    #print r['count']['value']
                    v = int(r['count']['value'])
                    if v < c:
                        print "ERROR"

    def checkRelationsExistance(self):
        print "Existence check"
        template = self.env.get_template('existenceCheck')
        if self.properties is None:
            return

        for prop in self.properties:
            p = prop['property']
            query = template.render(ontoClass=self.id, relationship=p)
            res1 = self.connection.query(query)
            for r in res1:
                print ">>", r

    @staticmethod
    def checkHirerarchy():
        env = Environment(loader=FileSystemLoader('tmpl'))
        connection = Connection('http://triples.101companies.org:8080/openrdf-sesame/')
        connection.use_repository('sandbox')

        connection.addnamespace('onto', 'http://101companies.org/ontology#')
        connection.addnamespace('res', 'http://101companies.org/resources#')
        template = env.get_template('subtypeCheck')
        print "Subtyping check"
        query = template.render()
        res = connection.query(query)
        x = list()
        for r in res:
            print r
            if not r.has_key('c'):
                t = ("Base: " + r['a']['value'], "First Child: " + r['b']['value'])
            else:
                t = ("Base: " + r['a']['value'], "First Child: " + r['b']['value'], "Second Child: " + r['c']['value'])
            if not t in x:
                x.append(t)
        print x
        with open('subtyping_errors.json', 'w') as outfile:
            json.dump(x, outfile)
开发者ID:MartinFSchmitz,项目名称:101worker,代码行数:82,代码来源:model.py


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