Hi,
I am writing a program to get the time stamp from system then save it to Ms access database using pyodbc,I have a time_stopped,Time_started column. When time_stopped is saved in DB for example,for the next signal it goes to next row,and save the time_started. But I want both of them in same row saved ,and then it can go to next row for saving the next time stamp.Thank u all Help me please
This is my code:
‘’’
if serialString == b'1\r\n' :
try:
com = """
insert into monitoring (line_name,time_stopped,time_started) VALUES ('G1.1', ?, ?)
"""
parameter1 = (x.strftime("%H:%M"))
parameter2 = (x.strftime("%Y/%m/%d"))
c.execute(com, parameter1,parameter2)
except:
print("error")
con.rollback()
print("line 1 stops at:")
print(now.tm_hour,end=":")
print(now.tm_min)
print(now.tm_year,end="/")
print(now.tm_mon,end="/")
print(now.tm_mday)
print('............................')
else:
try:
com = """
insert into monitoring (line_name,time_stopped,time_started) VALUES ('G1.1', ?, ?)
"""
parameter3 = (x.strftime("%H:%M"))
parameter4 = (x.strftime("%Y/%m/%d"))
c.execute(com, parameter3,parameter4)
except:
print("error")
con.rollback()
print("line 1 starts at:")
print(now.tm_hour, end=":")
print(now.tm_min)
print(now.tm_year, end="/")
print(now.tm_mon, end="/")
print(now.tm_mday)
print('............................')
‘’’
This is executed in a infinite while loop.