[Qgis-developer] pyqgis loading oracle table with sql expression

PIERRE Sylvain sylvain.pierre at bas-rhin.fr
Fri Jul 3 07:27:58 PDT 2015


Hi,

I'm trying to load oracle table with sql expression like explain here:
http://blog.georepublic.info/2013/joining-tables-with-sql-using-pyqgis/

My python code:
uriOracle = QgsDataSourceURI()
uriOracle.setSrid("EPSG:3948")
uriOracle.setConnection('xxxxxxxx', 'xxxxx','xxxxx', 'consultsig','consultsig')

uriOracle.setDataSource( "", "(select * from COMMUNE sort by ccocom)", "GEOM", "","id")

layer = QgsVectorLayer(uriOracle.uri(), 'communes', 'oracle')
if  not layer.isValid():
  print "Layer failed to load!"

But layer is not valid.
Did I miss something?
(I want to load layer but already sorted on a field value...)
Thanks

Sylvain



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150703/07563eb0/attachment.html>


More information about the Qgis-developer mailing list