def UpdateData(lVideoList, no_of_gate):
connection = sqlite3.connect('db.sqlite',
detect_types=sqlite3.PARSE_DECLTYPES |
sqlite3.PARSE_COLNAMES)
cursor = connection.cursor()
success = 200
unsuccess = 500
default_value = 0
for i in range(no_of_gate):
gate_id = i+1
for videofilename in lVideoList:
## print("videofilename: ", videofilename)
ldate = videofilename[0:10]
sql_select_Query = "select * from dailyfootfall where csv_name LIKE '"+ldate+"%'"
cursor.execute(sql_select_Query)
result = cursor.fetchall()
print(result)
if len(result)>0 :
try:
print ('Entry Not found...!!!')
insert_query = ("INSERT or IGNORE INTO dailyfootfall(csv_name, video_download, processed, footfall, send_status, "
"male_footfall, send_status_male, female_footfall, send_status_female, gate_id,outsiders, send_status_outsiders) "
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?)")
cursor.execute(insert_query,[videofilename, unsuccess, unsuccess, default_value, unsuccess, default_value,
unsuccess, default_value, unsuccess, gate_id, default_value, unsuccess])
print("Data_Inserted..!!")
print("="*20)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print("entry Not found"exc_type, fname, exc_tb.tb_lineno)
else:
try:
print ('Entry found...!!!')
cursor.execute("UPDATE dailyfootfall SET video_download=?, processed=?, footfall=?, send_status=? ,male_footfall=?, send_status_male=?, "
"female_footfall =?,send_status_female=?, outsiders=?, send_status_outsiders=? "
"WHERE csv_name=? AND gate_id=?", [unsuccess,unsuccess,default_value,unsuccess,default_value,unsuccess,default_value,
unsuccess,default_value,unsuccess,videofilename,gate_id])
print("Data_Updated..!!!")
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print("Entry found: "exc_type, fname, exc_tb.tb_lineno)
print("Data Inserted Successfully !")
connection.commit()
cursor.close()
connection.close()