def add_a_sugg(conn, name, mood, song_name, artist, url, comment): if name == None or mood == None or song_name == None or artist == None or url == None or comment == None or name == "" or mood == "" or song_name == "" or artist == "" or url == "" or comment == "": raise Exception return execute( conn, "INSERT INTO Suggestions(username,songname,artist,url,moodname,comment) VALUES (:username,:songname,:artist,:url,:moodname,:comment) ", { 'username': name, 'songname': song_name, 'artist': artist, 'url': url, 'moodname': mood, 'comment': comment })
def get_playlist(conn, mood): return execute( conn, "SELECT s.name, s.artist, s.url FROM Songs AS s, SongMood AS sm, Moods AS m WHERE s.sid = sm.sid and sm.mid = m.mid and m.mood = :mood", {'mood': mood})
def get_all_moods(conn): return execute(conn, "SELECT m.mid, m.mood FROM Moods AS m")
def suggestions(conn): return execute(conn, "SELECT * FROM Suggestions")
def songs(conn): return execute( conn, "SELECT s.sid, s.name, s.artist, s.url, s.explicit FROM Songs AS s")
def songmood(conn): return execute( conn, "SELECT songmood.sid, moods.mood, songs.name, songs.url FROM Songs, Moods, SongMood WHERE songs.sid = songmood.sid and moods.mid = songmood.mid" )