DatabaseHandler¶
-
class
mchartanalyzer.databasehandler.
DatabaseHandler
(testMode=None)[source]¶ Class responsible for handling database operations.
-
__weakref__
¶ list of weak references to the object (if defined)
-
_executeOperation
(statement, keepConnectionOpen=None)[source]¶ Executes a database operation, and doesn’t return a value. Intended for insert/update/delete operations. :param query:
-
_executeQuery
(query, keepConnectionOpen=None)[source]¶ Executes a query, and returns any retrieved rows. For queries that return no rows, this function will return an empty list. Intended for select statements. :param query: :return: rows
-
getAllChartsForArtist
(artistName)[source]¶ For a given artist, retrieves all their charts. If no charts are found, this returns an empty list.
-
getArtistByName
(artistName, keepConnectionOpen=None)[source]¶ Retrieves an artist with the given name. Returns “None” if a record isn’t found.
-
getArtistsWithFreshCharts
()[source]¶ Retrieves artists with charts that haven’t been analyzed yet. Returns an empty list if there are no such artists
-
getChartById
(chartId, keepConnectionOpen=None)[source]¶ Retrieves a chart with the given source URL. Returns “None” if a record isn’t found.
-
getChartByUrl
(sourceUrl, keepConnectionOpen=None)[source]¶ Retrieves a chart with the given source URL. Returns “None” if a record isn’t found.
-
getDefinitiveChartCalcsForArtist
(artistName)[source]¶ For a given artist, retrieves their “definitive” chart calculations. If no charts are found, this returns an empty list.
-
getDefinitiveChartsForArtist
(artistName)[source]¶ For a given artist, retrieves their “definitive” charts. If no charts are found, this returns an empty list.
-
getFreshChartsForArtist
(artistName)[source]¶ For a given artist, retrieves charts that haven’t been analyzed yet. Returns an empty list if there are no new charts.
-
getSongById
(songId, keepConnectionOpen=None)[source]¶ Retrieves a song with the given ID. Returns “None” if a record isn’t found.
-
getSongByTitleAndArtistName
(title, artistName, keepConnectionOpen=None)[source]¶ Retrieves a song with the given title. Returns “None” if a record isn’t found.
-
getSongsByArtist
(artistData)[source]¶ Retrieves all songs by the given artist. Returns an empty list if a record isn’t found.
-
initializeDatabase
()[source]¶ Initializes database. Creates database file if it doesn’t exist. If a database already exists, this function will delete it and recreate it!
-