0
我想調用一個使用cx_Oracle的cursor.callfunc()函數返回一個對象的Oracle函數。但是,這是行不通的gloabl name cx not defined
在這裏你可以看到我的代碼:
import cx_Oracle
import json
import web
urls = (
"/", "index",
"/grid", "grid",
)
app = web.application(urls, globals(),web.profiler)
web.config.debug = True
connection = cx_Oracle.Connection("TEST_3D/[email protected]:1521/sdetest")
typeObj = connection.gettype("MDSYS.SDO_GEOMETRY")
class index:
def GET(self):
return "hallo moritz "
class grid:
def GET(self):
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
web.header('Content-Type', 'application/json')
cursor = connection.cursor()
cursor.arraysize = 10000 # default = 50
cursor.execute("""SELECT a.id AS building_nr, c.Geometry AS geometry, d.Classname FROM building a, THEMATIC_SURFACE b, SURFACE_GEOMETRY c, OBJECTCLASS d WHERE a.grid_id_400 = 4158 AND a.id = b.BUILDING_ID AND b.LOD2_MULTI_SURFACE_ID = c.ROOT_ID AND c.GEOMETRY IS NOT NULL AND b.OBJECTCLASS_ID = d.ID""")
obj = cursor.fetchone()
obj = obj[1]
print obj
cursor.callfunc("SDO2GEOJSON", cx.Oracle.OBJECT, [obj])
# Aufruf der App
if __name__ == "__main__":
app.run(web.profiler)
錯誤消息: 在/格 全局名稱「CX」沒有定義
但我相信, cx_Oracle安裝正確。此外,我在開始時使用導入cx_Oracle,這是行得通的。
出了什麼問題?
你有'cursor.callfunc一個錯字( 「SDO2GEOJSON」,cx.Oracle.OBJECT,[OBJ])' – janos