def _iso8601_to_ts(s): """Parse ISO-8601 string to microsecond POSIX timestamp.""" try: s = str(s) if s.isnumeric(): # Valid type, no conversion required. return long(s) tm = time.strptime(s, '%Y-%m-%d %H:%M:%S') dt = datetime(*(tm[0:6] + (0, utc))) return to_utimestamp(dt) except (AttributeError, TypeError, ValueError): # Create a valid timestamp anyway. return to_utimestamp(datetime.now(utc))
def do_update(db): cursor = db.cursor() now = to_utimestamp(datetime.now(utc)) cursor.execute(""" UPDATE subscription SET changetime=%s, priority=%s WHERE id=%s """, (now, int(self.values['priority']), self.values['id']))
def do_update(db): cursor = db.cursor() now = to_utimestamp(datetime.now(utc)) cursor.execute( """ UPDATE subscription SET changetime=%s, priority=%s WHERE id=%s """, (now, int(self.values['priority']), self.values['id']))
def do_insert(db): cursor = db.cursor() priority = len(cls.find_by_sid_and_distributor(env, subscription['sid'], subscription['authenticated'], subscription['distributor'], db)) + 1 now = to_utimestamp(datetime.now(utc)) cursor.execute(""" INSERT INTO subscription (time,changetime,sid,authenticated, distributor,format,priority,adverb,class) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s) """, (now, now, subscription['sid'], subscription['authenticated'], subscription['distributor'], subscription['format'], int(priority), subscription['adverb'], subscription['class']) )
def do_insert(db): cursor = db.cursor() priority = len( cls.find_by_sid_and_distributor( env, subscription['sid'], subscription['authenticated'], subscription['distributor'], db)) + 1 now = to_utimestamp(datetime.now(utc)) cursor.execute( """ INSERT INTO subscription (time,changetime,sid,authenticated, distributor,format,priority,adverb,class) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s) """, (now, now, subscription['sid'], subscription['authenticated'], subscription['distributor'], subscription['format'], int(priority), subscription['adverb'], subscription['class']))