Skip to main content
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?


Forum|alt.badge.img
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?

Best answer by takashi

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.

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • December 21, 2015

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


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 21, 2015

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.


Forum|alt.badge.img
  • Author
  • December 21, 2015

@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()

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • December 21, 2015

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.


Forum|alt.badge.img
  • Author
  • December 21, 2015

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?


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • December 21, 2015
gouthami wrote:

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).


Forum|alt.badge.img
  • Author
  • December 21, 2015
takashi wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings