1

I have tried to add a layer from the Oracle database with SDO_GEOMETRY geometry, from the console that comes in QGIS, but it does not load anything, I occupy this because I want to put it in a plugin.

How can I load layers from oracle with the python editor that comes with Qgis?

SqlT = "select TABLE_NAME from all_tab_columns where data_type = 'SDO_GEOMETRY' and owner= 'GEOSERVER'"
cur.execute(sqlT)
tables = cur.fetchall()
uri = QgsDataSourceURI()
uri.setConnection("x.x.x.x","port","database","user","pass")

QgsProject.instance().writeEntry('WFSLayers',"/",[]) #investigar

for t in tables:
    print str(t[0])

uri.setDataSource(' ', str(t[0]), "GEOMETRY")
vlayer = QgsVectorLayer(uri.uri(), str(t[0]), 'oracle')
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
  • Welcome to GIS SE! As a new user please take the tour to learn about our focused Question and Answer format. What happens when you run that code? Does it do anything or give any errors? Please edit your question to include this information. – Midavalo Feb 8 '17 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.