Hi guess
Need some advice, the below code...
just after the imports I set gotEFTConnection = False
then I try and execute the following code.... I'm getting gotEFTConnection not set error from def eftdashboard()
Pretty sure I'm running into variable scope problem...
How do I pass a variable into a flask function ( => eftdashboard) and then how do I return a value, so that it's now set to True.
Need some advice, the below code...
just after the imports I set gotEFTConnection = False
then I try and execute the following code.... I'm getting gotEFTConnection not set error from def eftdashboard()
Pretty sure I'm running into variable scope problem...
How do I pass a variable into a flask function ( => eftdashboard) and then how do I return a value, so that it's now set to True.
import sys import datetime eft_connectString = '' # Empty variable to be used for connection string FLASK_DEBUG = False DEBUGLEVEL = 1 # My Debug level/s -> To Screen/terminal gotEFTConnection = False # some code... def GetEFTDBConnection(eft_connectString, opswatchenv): # Get the connection to the database try: ########## EFT Database Connection and Cursor eft_connection = cx_Oracle.connect(eft_connectString) # Query all rows eft_cursor = eft_connection.cursor() if DEBUGLEVEL > 0: print "** ", opswatchenv, " - EFT ConnectString :", eft_connectString print "** ", opswatchenv, " - Connected to EFT DB :", eft_connection print "** ", opswatchenv, " - EFT Query Cursor :", eft_cursor # end if DEBUG > 0: return eft_cursor except Exception, e: print "** ", opswatchenv, "Exception :", e print '' # end DEBUG > 0: # end try # end GetEFTDBConnection(): @app.route("/") def main(): return render_template("index.html") #end main @app.route("/eftdashboard") def eftdashboard( ): # One Single Dashboard with all the EFT information # if gotEFTConnection == False: # eft_cursor = GetEFTDBConnection(eft_connectString, opswatchenv) # gotEFTConnection = True # end if gotEFTConnection: configurationsettings, delivery_date, next_output_date = eft_refreshsettings(eft_cursor)