本文整理汇总了Python中api_li3ds.database.Database类的典型用法代码示例。如果您正苦于以下问题:Python Database类的具体用法?Python Database怎么用?Python Database使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Database类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transfo_trees
def transfo_trees(name, url, label, ids):
edges = Database.query(
"""
select t.id, t.source, t.target, t.transfo_type, t.name, tft.name as tname
from (
select distinct
unnest(tt.transfos) as tid
from li3ds.transfo_tree tt where tt.id = ANY(%s)
) as tf
join li3ds.transfo t on t.id = tf.tid
join li3ds.transfo_type tft on tft.id = t.transfo_type
""", (list(ids), )
)
urefs = set()
for edge in edges:
urefs.add(edge.source)
urefs.add(edge.target)
nodes = Database.query("""
select distinct r.id, r.name, r.sensor, s.name as sname, s.type
from li3ds.referential r
join li3ds.sensor s on r.sensor = s.id
where ARRAY[r.id] <@ %s
""", (list(urefs), ))
return make_dot(name, url, label, nodes, edges)
示例2: post
def post(self):
'''
Import foreign schema for a rosbag file
'''
req = sql.SQL("""
create schema if not exists {schema};
select coalesce(max(pcid) + 1, 1) as pcid from pointcloud_formats
""").format(schema=sql.Identifier(api.payload['schema']))
pcid = Database.query_asdict(req)[0]['pcid']
identifiers = {k: sql.Identifier(v) for k, v in api.payload.items()}
req = sql.SQL("""
import foreign schema {rosbag} limit to (pointcloud_formats)
from server {server} into {schema} options (pcid %(pcid)s);
insert into pointcloud_formats select pcid, srid, schema
from {schema}.pointcloud_formats;
import foreign schema {rosbag} except (pointcloud_formats)
from server {server} into {schema} options (pcid %(pcid)s)
""").format(**identifiers)
Database.rowcount(req, {'pcid': str(pcid)})
return "foreign schema imported", 201
示例3: delete
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
示例4: get
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,)
)
示例5: get
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,))
示例6: post
def post(self):
'''Create a session'''
return Database.query_asdict(
"insert into li3ds.session (name, start_time, end_time, project, platform) "
"values (%(name)s, %(start_time)s, %(end_time)s, %(project)s, %(platform)s) "
"returning *",
defaultpayload(api.payload)
), 201
示例7: get
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
示例8: get
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
示例9: get
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
示例10: get
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
示例11: post
def post(self):
'''Create a transformation between referentials'''
return Database.query_asdict(
"""
insert into li3ds.transfo_tree (name, owner, transfos)
values (%(name)s,%(owner)s,%(transfos)s)
returning *
""",
defaultpayload(api.payload)
), 201
示例12: post
def post(self):
'''Create a transformation type'''
return Database.query_asdict(
"""
insert into li3ds.transfo_type (name, description, func_signature)
values (%(name)s,%(description)s,%(func_signature)s)
returning *
""",
defaultpayload(api.payload)
), 201
示例13: create_app
def create_app():
"""
Creates application.
:returns: flask application instance
"""
app = Flask(__name__)
cfgfile = os.environ.get('API_LI3DS_SETTINGS')
if cfgfile:
app.config.update(load_yaml_config(cfgfile))
else:
try:
cfgfile = (Path(__file__).parent.parent / 'conf' / 'api_li3ds.yml').resolve()
except FileNotFoundError:
print(Path(__file__).parent.parent / 'conf' / 'api_li3ds.yml')
app.logger.warning('no config file found !!')
sys.exit(1)
app.config.update(load_yaml_config(str(cfgfile)))
# setting log level
if app.config['DEBUG']:
app.logger.setLevel(LOG_LEVELS['debug'])
else:
app.logger.setLevel(LOG_LEVELS['info'])
app.logger.debug('loading config from {}'.format(cfgfile))
if 'HEADER_API_KEY' not in app.config:
app.logger.fatal('HEADER_API_KEY missing')
sys.exit(1)
if not app.config['HEADER_API_KEY'] or len(app.config['HEADER_API_KEY']) < 12:
app.logger.fatal('HEADER_API_KEY cannot be empty or '
'too short (at least 12 characters)')
sys.exit(1)
# load extensions
# be carefull to load apis before blueprint !
init_apis()
api.init_app(app)
Database.init_app(app)
return app
示例14: post
def post(self):
'''Create a sensor'''
return Database.query_asdict(
"""
insert into li3ds.sensor (name, serial_number, brand,
model, description, specifications, type)
values (%(name)s, %(serial_number)s, %(brand)s,
%(model)s, %(description)s, %(specifications)s, %(type)s)
returning *
""",
defaultpayload(api.payload)
), 201
示例15: post
def post(self):
'''
Create a project.
'''
if 'timezone' not in api.payload:
api.payload.update(timezone=project_model_post['timezone'].default)
return Database.query_asdict(
"insert into li3ds.project (name, timezone, extent) "
"values (%(name)s, %(timezone)s, ST_Transform(%(extent)s::geometry,4326)) "
"returning *",
defaultpayload(api.payload)
), 201