I have been trying over and over to get csv data to write on a task. I have tried python3, python3.8 and no luck either way. If I click run manually the csv will write but if it's on a scheduled task it won't. How can I fix this? Any help would be greatly appreciated! Thank you
def witness_query(statement, args = None): cursor = zohoDB.cursor() cursor.execute(statement, args)
if "select" == statement.split()[0]:
result = cursor.fetchall()
# print(result)
c = csv.writer(open("witness_analytics.csv","w"))
c.writerow(['record_id', 'address', 'witness_list', 'witness_count', 'lat', 'lng', 'accessed'])
for row in result:
# c.writerow(row)
# print(row)
c.writerow(row)
cursor.close()
return result
else:
zohoDB.commit()
cursor.close()