def updateDB(self, job): logtype = job.getType() if logtype == 'M': songid = 0 while songid == 0: sql = "SELECT id FROM songs WHERE filename = ?" self.cur.execute(sql, [job.message]) if self.cur.rowcount < 1: sql = "INSERT INTO songs (filename) VALUES (?)" self.cur.execute(sql, [job.message]) self.con.commit() else: songid = self.cur.fetchone() sql = "INSERT INTO playlist (date, song) VALUES (?, ?)" args = (job.getTimestamp("%Y-%m-%d %H:%M:%S"), songid) self.cur.execute(sql, args) self.con.commit() else: sql = "INSERT INTO playlist (date, song) VALUES (?, 1)"