Need help fixing this error please:NameError: global name is not defined
Peter Otten
__peter__ at web.de
Thu Sep 6 07:07:28 EDT 2012
shaun wrote:
> I have a class which I create an object from in a different script but
when its run I get an error at the last part of this method:
> def databasebatchcall(self,tid, bid):
> con=cx_Oracle.connect(
> 'user/user123 at odb4.dcc.company/ODB4TEST.COMPANY.COM')
> cur = con.cursor()
> cur.execute("SELECT * FROM name)
> results = cur.fetchall()
This is not your real code. The above would give you a SyntaxError in the
line
> cur.execute("SELECT * FROM name)
> From this last line I get the following error which I don't understand I'm
very new to python and have no idea about this any help would be appreciated
> File "/home/dcroke/mdcFDACStringCall.py", line 21, in fetchbatchdata
> results = cur.fetchall()
> NameError: global name 'cur' is not defined
The offending line may not be indented correctly:
def databasebatchcall(...):
...
cur = con.cursor()
...
results = cur.fetchall()
This may be obscured by mixing tabs and spaces. However, without the actual
code this is nothing but a guess.
More information about the Python-list
mailing list