Cannot get updated DB Data with PYODBC and FLASK Python -


i seem having issues querying pyodbc connection flask connection in python. had entire file using same connection, noticed when hit url request not return recent data. adjusted script start , kill connection each time request initiated returns same non updated data. notice update data times not.

please assist better clarify process.

def getchg(s, cursor, arr): getincresolved = "select count(incident.number) schema.oauser.incident incident incident.dv_resolved_by = '" + str(s) + "' , incident.resolved_at between '" + str(past) + "' , '" + str(current) + "' , incident.dv_opened_by != '" + str(s) + "';" gettaskresolved = "select count(sc_task.number) schema.oauser.sc_task sc_task sc_task.dv_closed_by = '" + str(s) + "' , sc_task.closed_at between '" + str(past) + "' , '" + str(current) + "' , sc_task.dv_opened_by != '" + str(s) + "';" getcallstarted = "select count(new_call.number) schema.oauser.new_call new_call  new_call.opened_at between '" + str(past) + "' , '" + str(current) + "' , new_call.dv_opened_by = '" + str(s) + "';" = 0 t = 0 c = 0 cursor.execute(getincresolved) row in cursor.fetchall():     = row[0]  cursor.execute(gettaskresolved) row in cursor.fetchall():     t = row[0] cursor.execute(getcallstarted) row in cursor.fetchall():     c = row[0] if c > -1:     test = {'agent': str(s), 'calls': c, 'inc': i, 'task': t}     arr.append(test)    @app.route('/data',methods=['get', 'post']) def api_root():  cnxn=pyodbc.connect('dsn=servicenow;uid=serviceops;pwd=********;',autocommit=true) cursor = cnxn.cursor() data = [] staffjson = request.get_json(force=true) staff = staffjson['users'] print(staff) del data[:] s in staff:     getchg(s, cursor, data) print(data) cnxn.close() return json.dumps(data) 

the current variable being created @ initial start of script. therefore once loaded never updated current time.

created variable @ each request , working expected.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -