I would like to use the QGIS modeller (or similar) to import SQL query results form my Database directly into my workspace.
I am asking as part of my job is to repetitively add vector and DTM layers from our Server and clip them to a smaller size based on the Site boundary provided by the client. I have now managed to at least add the vector layers correctly, Haven't had much luck with the Raster layers yet TBH, and buffer this Boundary by 1km and insert the Layer using DB manager.
The SQL I have used is as follows-
SELECT vectors_index__21.gid, vectors_index__21.fid,vectors_index__21.geom, st_contains(ST_Buffer(public.site_boundary.geom,1000)public.vectors_index__21.geom)
FROM public.site_boundary, public.vectors_index__21
WHERE st_contains(ST_Buffer(public.site_boundary.geom,1000), public.vectors_index__21.geom) IS TRUE
GROUP BY vectors_index__21.gid,vectors_index__21.fid,vectors_index__21.geom, site_boundary.geom
Can I add this code to a QGIS model or script that will do this task multiple times, ie. with different vector and raster layers so that the workspace basically sets itself up each time once the new site boundary has been added to my database and SQL syntax updated?
I have looked eveywhere for this type of functionality but so far my only option seems to be the DB manager to import my results to a workspace. Has anyone done this before or have any suggestions?Everyone loves a good bit of automation in their lives.