當前位置: 首頁>>代碼示例>>Python>>正文


Python database.Database類代碼示例

本文整理匯總了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)
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:28,代碼來源:dot.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:25,代碼來源:foreignpc.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:9,代碼來源:project.py

示例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,)
     )
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:10,代碼來源:project.py

示例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,))
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:7,代碼來源:session.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:8,代碼來源:session.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:8,代碼來源:platform.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:8,代碼來源:referential.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:8,代碼來源:sensor.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:8,代碼來源:transfotree.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:10,代碼來源:transfotree.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:10,代碼來源:transfo.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:42,代碼來源:__init__.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:12,代碼來源:sensor.py

示例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
開發者ID:LI3DS,項目名稱:lids-api,代碼行數:12,代碼來源:project.py


注:本文中的api_li3ds.database.Database類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。