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


Python Database.query_asjson方法代码示例

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


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

示例1: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, name):
     '''List all sessions for a given project'''
     res = Database.query_asjson("select * from li3ds.project where name=%s", (name,))
     if not res:
         nsproject.abort(404, 'Project not found')
     return Database.query_asjson(
         """select s.* from li3ds.session s
         join li3ds.project p on s.project=p.id where p.name=%s
         """, (name,)
     )
开发者ID:LI3DS,项目名称:lids-api,代码行数:12,代码来源:project.py

示例2: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, id):
     '''List session datasources'''
     return Database.query_asjson(
         """select d.* from li3ds.session s
         join li3ds.datasource d on d.session = s.id
         where s.id = %s
         """, (id,))
开发者ID:LI3DS,项目名称:lids-api,代码行数:9,代码来源:session.py

示例3: post

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
    def post(self):
        '''
        Create a foreign server
        '''
        drivers = Database.notices(multicorn_drivers_sql)[-1]
        drivers = drivers.strip('NOTICE: \n').split(',')

        if api.payload['driver'] not in drivers:
            return abort(
                400,
                '{} driver does not exist, available drivers are {}'
                .format(api.payload['driver'], drivers))

        options = api.payload['options']
        options.update(wrapper=api.payload['driver'])
        options = {k: str(v) for k, v in options.items()}

        options_sql = sql.SQL(', ').join([
            sql.SQL(' ').join((sql.Identifier(opt), sql.Placeholder(opt)))
            for opt in options
        ])

        req = sql.SQL("""
            create server {name} foreign data wrapper multicorn options (
                {options}
            );
        """).format(name=sql.Identifier(api.payload['name']), options=options_sql)

        Database.rowcount(req, options)

        req = servers_sql + ' where srvname = %(name)s'

        return Database.query_asjson(req, api.payload), 201
开发者ID:LI3DS,项目名称:lids-api,代码行数:35,代码来源:foreignpc.py

示例4: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, id):
     '''Get one platform given its identifier'''
     res = Database.query_asjson(
         "select * from li3ds.platform where id=%s", (id,)
     )
     if not res:
         nspfm.abort(404, 'Platform not found')
     return res
开发者ID:LI3DS,项目名称:lids-api,代码行数:10,代码来源:platform.py

示例5: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, id):
     '''Get one transformation given its identifier'''
     res = Database.query_asjson(
         "select * from li3ds.transfo_tree where id=%s", (id,)
     )
     if not res:
         nstft.abort(404, 'Transformation tree not found')
     return res
开发者ID:LI3DS,项目名称:lids-api,代码行数:10,代码来源:transfotree.py

示例6: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, id):
     '''Get one sensor given its identifier'''
     res = Database.query_asjson(
         "select * from li3ds.sensor where id=%s", (id,)
     )
     if not res:
         nssensor.abort(404, 'sensor not found')
     return res
开发者ID:LI3DS,项目名称:lids-api,代码行数:10,代码来源:sensor.py

示例7: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self, id):
     '''Get one referential given its identifier'''
     res = Database.query_asjson(
         "select * from li3ds.referential where id=%s", (id,)
     )
     if not res:
         nsrf.abort(404, 'Referential not found')
     return res
开发者ID:LI3DS,项目名称:lids-api,代码行数:10,代码来源:referential.py

示例8: delete

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def delete(self, name):
     '''
     Delete a project.
     '''
     res = Database.query_asjson("select * from li3ds.project where name=%s", (name,))
     if not res:
         nsproject.abort(404, 'Project not found')
     Database.query_aslist("delete from li3ds.project where id=%s", (name,))
     return '', 410
开发者ID:LI3DS,项目名称:lids-api,代码行数:11,代码来源:project.py

示例9: get

# 需要导入模块: from api_li3ds.database import Database [as 别名]
# 或者: from api_li3ds.database.Database import query_asjson [as 别名]
 def get(self):
     '''
     Retrieve foreign view list
     '''
     return Database.query_asjson(views_sql)
开发者ID:LI3DS,项目名称:lids-api,代码行数:7,代码来源:foreignpc.py


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