Example #1
0
 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']
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)