I have two layers(layer1,layer2) in PostGIS database where I have connect in QGIS project.
My database have specific precision. Now I want to use from QGIS processing some algorithms like GISDIFFERENCE(for example I know tew postgis have query for this). But I don't know how to import the algorithm output in PostGIS database automatic to keep my database precision.
For example, if I try to run graphical this tool show me choose to save as to PostGIS database. Because I want to create a QGIS plugin.
Some way is to run algorithms and I save manual the output to shapefile and after to import this shapefile to PostGIS database like this :
outputs_QGISDIFFERENCE_1=processing.runalg('qgis:difference', layer1,layer2,False,None)
load= QgsVectorLayer(outputs_QGISDIFFERENCE_1['OUTPUT'],'myname', 'ogr')
QgsMapLayerRegistry.instance().addMapLayer(load)
and save to PostGIS database.
But that way create it me topology error because I loose the database precision if I use the graphical way to save as to PostGIS database then that layer is correct.
But how to do this using PyQGIS?