def save_start_time(stime): row = conn.execute(notify_logs.select().\ where(notify_logs.c.type == 'spooler')).fetchone() if row is None: conn.execute(notify_logs.insert(values={'type': 'spooler', 'time': stime})) logging.error('inserting to db the stime: %s' % stime) else: r = conn.execute(notify_logs.update(notify_logs.c.type == 'spooler', values={'time': stime})) logging.error('updating to db the stime: %s' % stime)