Esempio n. 1
0
    def get_songs(self):
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS
'''
        cursor.execute(sql)
        ret = []

        while True:
            data = cursor.fetchone()
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]
                
                yield song
            else:
                break
Esempio n. 2
0
    def find_songs_by_title(self, title):
        "노래 제목으로 곡을 찾는다."

        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where title like ?
'''
        cursor.execute(sql, (title, ))
        ret = []

        for data in cursor.fetchmany(5):
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]

                ret.append(song)
        
        return ret
Esempio n. 3
0
    def get_songs(self):
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS
'''
        cursor.execute(sql)
        ret = []

        while True:
            data = cursor.fetchone()
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]

                yield song
            else:
                break
Esempio n. 4
0
    def find_songs_by_title(self, title):
        "노래 제목으로 곡을 찾는다."

        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where title like ?
'''
        cursor.execute(sql, (title, ))
        ret = []

        for data in cursor.fetchmany(5):
            if data:
                song = Song()

                song.dbid = data[0]
                song.uid = data[1]
                song.title = data[2]
                song.artist = data[3]
                song.url = data[4]
                song.img_url = data[5]
                song.played_count = data[6]
                song.created_at = data[7]
                song.description = data[8]
                song.duration = data[9]

                ret.append(song)

        return ret
Esempio n. 5
0
    def find_by_id(self, dbid):
        "UID로 노래를 찾는다."
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where id = ?
'''
        cursor.execute(sql, (dbid, ))
        data = cursor.fetchone()
        if data:
            song = Song()

            song.dbid = data[0]
            song.uid = data[1]
            song.title = data[2]
            song.artist = data[3]
            song.url = data[4]
            song.img_url = data[5]
            song.played_count = data[6]
            song.created_at = data[7]
            song.description = data[8]
            song.duration = data[9]
            
        return song
Esempio n. 6
0
    def find_by_id(self, dbid):
        "UID로 노래를 찾는다."
        cursor = self.db.cursor()
        sql = '''\
select id, uid, title, artist, url, img_url, played_count, created_at, description, duration FROM SONGS where id = ?
'''
        cursor.execute(sql, (dbid, ))
        data = cursor.fetchone()
        if data:
            song = Song()

            song.dbid = data[0]
            song.uid = data[1]
            song.title = data[2]
            song.artist = data[3]
            song.url = data[4]
            song.img_url = data[5]
            song.played_count = data[6]
            song.created_at = data[7]
            song.description = data[8]
            song.duration = data[9]

        return song