Solved

In the FME ,we have included python startup script. When we run it in FME 2014 version, it showing an error like : name 'dbCursor' is not defined.Could you please temme what would be the reason?

  • 21 December 2015
  • 7 replies
  • 2 views

Badge
In the FME ,we have included python startup script. When we run it in FME 2014 version, it showing an error like : name 'dbCursor' is not defined.Could you please temme what would be the reason?
icon

Best answer by takashi 21 December 2015, 06:18

View original

7 replies

Badge +2

Hi,

I don't know python but when I tried for first-time even I too received the error.

In Python, position of starting of line and ending of line is most important. So re-write the script in editor in the position where it starts and end.

Hope this helps :)

Pratap

Userlevel 2
Badge +17

The error occurs if a variable called "dbCursor" is not defined before using it in the script. Cannot think of other things unless seeing the actual script.

Badge

@takashi Here is the actual script

import fmeobjects

 

import cx_Oracle

 

import sys

 

#Getting the database paramters

 

service = FME_MacroValues['DBService']

 

userName = FME_MacroValues['DBUserName']

 

password = FME_MacroValues['DBPassword']

 

updateImportIDProc= 'NBN_DATA_OWNER.UPDATE_NBN_DATA_LOG'

 

getImportIDProc = 'NBN_DATA_OWNER.GET_NBN_IMPORT_ID'

 

#Getting the current process Id

 

importID =-1

 

#Creating connecting strings

 

connectionString = userName + '/' + password + '@' + service

 

try:

 

dbConnection = cx_Oracle.connect(connectionString)

 

dbCursor = dbConnection.cursor()

 

dbCursor.callproc(updateImportIDProc,('UPLOADING','NBN_FPRNT'))

 

#checking the run status of 01_CleanUp_Input.fmw workspace

 

id = dbCursor.var(cx_Oracle.NUMBER)

 

dbCursor.callproc(getImportIDProc,('NBN_FPRNT',id))

 

#raise Exception("Translation failed, 01_CleanUp_Input.fmw is not yet finished")

 

importID = id.getvalue()

 

if importID==-1:

 

raise Exception(message)

 

if dbCursor is not None:

 

dbCursor.close()

 

dbCursor=None

 

if dbConnection is not None:

 

dbConnection.commit()

 

dbConnection.close()

 

dbConnection=None

 

except Exception, e:

 

print str(e)

 

importID = -1;

 

if dbCursor is not None:

 

dbCursor.close()

 

dbCursor=None

 

if dbConnection is not None:

 

dbConnection.commit()

 

dbConnection.close()

 

dbConnection=None

 

sys.exit()
Userlevel 2
Badge +17

The variable "dbCursor" is defined inside of the "try" block, so it cannot be accessed from the "except" block. Try inserting these lines before the try block.

dbCursor = None
dbConnection = None

Indentations are important in Python scripts. Please use the CODE block when posting a script in the next time.

Badge

Thnq @takashi ...it got resolved. And now iam getting an error saying like

 

Unable to configure the XML module to read the XML dataset. No <xrs:switch> item in the xrs document 'D:\\apps\\FME\\xml\\xrs\\xrs.xml' matched the XML dataset 'D:\\IDW\\Data\\XML\\Historical Footprint List C.xml'

The XML format could not be determined by examination. Try entering a feature path into the "Elements to Match" parameter, specifying an xfMap, selecting an XRS, or using a more specific reader

The XML Module halted on error, see the logfile for details

Could you please help me in dis?

Userlevel 2
Badge +17

Thnq @takashi ...it got resolved. And now iam getting an error saying like

 

Unable to configure the XML module to read the XML dataset. No <xrs:switch> item in the xrs document 'D:\\apps\\FME\\xml\\xrs\\xrs.xml' matched the XML dataset 'D:\\IDW\\Data\\XML\\Historical Footprint List C.xml'

The XML format could not be determined by examination. Try entering a feature path into the "Elements to Match" parameter, specifying an xfMap, selecting an XRS, or using a more specific reader

The XML Module halted on error, see the logfile for details

Could you please help me in dis?

Looks like the error is from an XML reader in your workspace. Isn't it?

If so, please post it as a new question (with more detailed explanation about the reader setting so that we can understand the situation).

Badge

Looks like the error is from an XML reader in your workspace. Isn't it?

If so, please post it as a new question (with more detailed explanation about the reader setting so that we can understand the situation).

yeah @takashi sorry...now everything is fine thnqqq

Reply