def store(self): db = Database() # TODO: don't search on uri, do a comparison on more metadata db.commit_statement('''select * from tracks where uri = ?''', [self.uri]) row = db.fetchone() if row == None: db.commit_statement('''insert into tracks (title, artist, album, uri, duration) values (?, ?, ?, ?, ?)''', (self.title, self.artist, self.album, self.uri, self.duration)) return db.inserted_id() else: return row['id']
def create(self, name): db = Database() db.commit_statement("""insert into playlists (name) values (?)""", [name]) logging.debug("Adding playlist '" + name + "'") return Playlist(db.inserted_id(), name, db)
def create(self, name): db = Database() db.commit_statement('''insert into playlists (name) values (?)''', [name]) print "Adding playlist '" + name + "'" return Playlist(db.inserted_id(), name, db)
def add(self, user, passw, type): db = Database() db.commit_statement('''insert into sources (user, password, type) values (?, ?, ?)''', [user, passw, type]) logging.debug ("Adding source '" + user + " " + passw + " " + type + "'") return Source(db.inserted_id(), user, passw, type, db)