예제 #1
0
    def load_information(self, ServerName, DatabaseName):

        # Load Tables
        self.FoobarDB = AppDB(Server(ServerName).connect_to(DatabaseName))

        self.tblArtists = self.FoobarDB.load_table('tblArtists')
        self.tblAlbums = self.FoobarDB.load_table('tblAlbums')
        self.tblSongs = self.FoobarDB.load_table('tblSongs')
        self.tblArtistsSongs = self.FoobarDB.load_table('tblArtistsSongs')

        # Text indicators
        self.Online_QLabel.setText("The database is online.")
        self.Artists_QLabel.setText(f"There are {self.tblArtists.count_records()} artists in the database.")
        self.Albums_QLablel.setText(f"There are {self.tblAlbums.count_records()} albums in the database.")
        self.Songs_QLabel.setText(f"There are {self.tblSongs.count_records()} songs in the database.")
        self.SongsArtists_QLabel.setText(f"There are {self.tblArtistsSongs.count_records()} pairs of songs-artists data in the database.")

        # Table data
        CommonArtists_DataFrame = pd.read_sql('SELECT * FROM viewMostAppArtists ORDER BY Appearances DESC', self.FoobarDB.Connection)
        self.Model = Model(CommonArtists_DataFrame.iloc[:, :5])
        self.QTableView.setModel(self.Model)
        self.QTableView.resizeColumnsToContents()
        self.QTableView.setColumnWidth(1, 180)
        self.QTableView.resizeRowsToContents()

        # Comboboxes
        self.Genre_QComboBox.addItems(self.tblArtists.get_genre_list())
        self.Type_QComboBox.addItems(self.tblArtists.get_type_list())
        self.Sex_QComboBox.addItems(self.tblArtists.get_sex_list())

        # Status Bar
        self.QStatusBar.showMessage(f'Last Update: {self.FoobarDB.get_last_scrape()}')
예제 #2
0
    def attempt_connection(self):

        self.Server = Server(self.Server_String)

        # try:
        AppDatabase = AppDB(self.Server.connect_to(self.Database_String))
        if not AppDatabase.Status == 'Error':
            self.open_main()
        else:
            self.display_repair_message()