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

getAllArtists()[source]

Retrieves artists. Returns an empty list if there are no such artists

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.

getChartsForSong(artistData, songData)[source]

Retrieves all charts for a given song.

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!

purgeDatabase()[source]

Removes all data from the database.

saveArtistCalculationData(chartData)[source]

Saves artist calculations to the database.

saveArtistData(artistData)[source]

Saves artist data to the database.

saveChartCalculationData(chartData, chartCalcs)[source]

Saves chart calculations to the database.

saveChartData(artistData, songData, chartData, isDefinitiveChart)[source]

Saves chart data to the database. If a chart with the same URL exists, the existing record is updated with the newer chords and sections.

saveSongData(artistData, songData)[source]

Saves song data to the database. If a song with the same name exists in the database, nothing happens.