Able to connect to Oracle Spatial 11g and print tables with SDO_GEORASTER attribute both in QGIS python console and standalone application.I get below error when loading rasters from oracle Table.
Traceback (most recent call last): File "", line 1, in Exception: unknown
strProjetName = "C:/OSGeo4W/apache/htdocs/QGIS-Web-Client-master/projects/myworld.qgs"
def add_LayersFromDB():
QGISAPP = QgsApplication(sys.argv, True)
QgsApplication.setPrefixPath(r"C:\OSGeo4W\apps\qgis", True)
QgsApplication.initQgis()
#Connect to Oracle and Fetch Table Names
con = cx_Oracle.connect('myoradb/[email protected]:1521/newdev')
print con.version
cur = con.cursor()
cur.execute(u"select TABLE_NAME from user_tab_columns where data_type='SDO_GEORASTER'")
tables = cur.fetchall()
print tables
QgsProject.instance().setFileName(strProjetName)
print QgsProject.instance().fileName()
render = QgsMapRenderer()
uri = QgsDataSourceURI()
uri.setConnection("189.53.61.140", "1521", "newdev", "myoradb", "myoradb")
render = QgsMapRenderer()
for t in tables :
print str(t[0])
uri.setDataSource('', str(t[0]), "RAST")
uri.uri()
vlayer = QgsRasterLayer(uri.uri(),str(t[0]), 'oracle') #FAILS HERE
QgsMapLayerRegistry.instance().addMapLayer(vlayer)
lst = [ vlayer.id() ]
render.setLayerSet(lst)
rect = QgsRectangle(render.fullExtent())
rect.scale(1.1)
render.setExtent(rect)
QgsProject.instance().write()
cur.close()
con.close()
QgsApplication.exitQgis()
add_LayersFromDB()