All pastes #219514 Raw Edit

Someone

public text v1 · immutable
#219514 ·published 2006-10-24 18:55 UTC
rendered paste body
        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()