本文整理汇总了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,)
)
示例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,))
示例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
示例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
示例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
示例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
示例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
示例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
示例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)