def insert_refdata(config): ci_db_helper = PGDbHelper(config.pgsql_conn_str()) logger.info("Insert special coordinate systems %s" % config.dbname) for spref in SPREFS: ci_db_helper.execute(spref.sql_insert_statement) #insert custom functions for calculating du/dx, dv/dx logger.info("Inserting special plp/sql procedures %s" % config.dbname) from namo_app.db.models import init_mapper init_mapper(sqa_conn_str=config.sqa_connection_string()) logger.info("Inserting ref data on %s" % config.dbname) from namo_app.db.ref_data import PROVIDERS, VARIABLES, FORMATS with SqaAccess(conn_str=config.sqa_connection_string()) as sqa: logger.info("Inserting variables") sqa.insert(VARIABLES) logger.info("Inserting formats") sqa.insert(FORMATS) logger.info("Inserting providers") sqa.insert(PROVIDERS)
def rastertile(datagranule_id): from namo_app.db.access import SqaAccess from namo_app.config import Config, get_env from namo_app.db.models import init_mapper, Mask, RasterTile, DataGranule, DataFormat from flask import request #q {"filters":[{"name":"datagranule_id","op":"==","val":"3"}]} config = Config(env=get_env()) init_mapper(config.sqa_connection_string()) mask = request.args.get('mask', None) with SqaAccess(conn_str=config.sqa_connection_string()) as sqa: tileObjs = sqa.all(RasterTile, filterr={'datagranule_id': datagranule_id}) response = flask.json.dumps({"tiles": tileObjs}) return response
__author__ = 'ujjwal' from namo_app.config import Config, get_env from namo_app.db.models import init_mapper config = Config(env=get_env()) init_mapper(sqa_conn_str=config.sqa_connection_string())