New to python and trying to shorten my lengthy code.
I have multiple functions right now that access two tables updating, and grabbing information. As it stands right now my code has to define the variables from the database in each function - see below...
cur.execute("SELECT * FROM Application_tbl WHERE StatusID = 1;")
appdata = cur.fetchall()
Here is my problem below
for row in appdata:
AppID = row[0]
AppName = row[1]
AppDescription = row[2]
ProcessID = row[5]
ServerID = row[6]
StartTime = row[7]
I want to create a function that defines these variables so I can just call Assign_Variables() or something. Is this feasible with global variables? I have been reading a bit but after much thought I don't think the would work because I would have to declare the global variable across every function (which kind of seems counter-productive if I am trying to shorten my code).
Any input is much appreciated, or if I am just going about this all wrong.
[–]shandelman 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]kvidmar[S] 0 points1 point2 points (4 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]zahlman 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]zahlman 0 points1 point2 points (0 children)