def load_layers(self): """Load the layer configuration for the datasource""" try: with open("data_loader/"+self.config["layer_config"], 'r') as f: config = yaml.load(f) for layer in config["layers"]: shapeformat = layer["file"].rsplit('.', 1)[-1] shapefile = self.dir+layer["file"] if shapeformat == "shp": self.shp2pgsql(shapefile, layer['table']) if shapeformat == "tif": self.raster2pgsql(shapefile, layer['table']) # Alter the table if needed try: query = layer["alter"].format(table=layer['table']) utils.psycopg_atlas(query) except: pass except KeyError: print "No configuration file found for {}".format(self.name)
def sql2pgsql(self, sql): utils.psycopg_atlas(sql) print "Loaded schema into database"