class db: def __init__(self): #constructor conn = sqlite3.connect('./db.db') conn.isolation_level = None self.cursor = conn.cursor() try: self.cursor.execute("CREATE TABLE database (album,filepath)" ) except: pass
def add_entry( self, eone , etwo ): #Add entry to database self.cursor.execute( "INSERT INTO database (album,filepath) VALUES (?,?)", ( eone , etwo ) ) return 1 #TODO: exception handler def get_mediadb( self, print_db = False ): self.cursor.execute( 'SELECT * FROM database' ) if (print_db == True): print self.cursor.fetchall() def get_value( self, column ): self.cursor.execute( "SELECT %s FROM database" % column ) for n in self.cursor: print n def destructor(self): self.cursor.close() def walking_and_filling(db): pass if __name__ == "__main__": db = db() #walking_and_filling( db ) for root, dirs, files in os.walk( '''foo_path/''', topdown=False ): for name in files: joined = os.path.join(root, name) if (name[-3:] == 'mp3' and os.path.isfile( joined ) ): try: audio = MP3 (joined, ID3=EasyID3 ) print (audio['album']) db.add_entry( joined, audio['album'] ) except: pass db.get_mediadb( print_db=True ) When i execute this the database doesn't get filled with anything and the program stays running in memory for ever. The print statement is just a Unicode string that would get to the database if i stated it in the add_entry function as a constant string. It's a really weird problem that i dont seem to understand why it's working out this way. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list