Database managment module¶
SQlite database library
-
class
sima.lib.simadb.
SimaDB
(db_path=None)[source]¶ SQLite management
-
add_history
(track, date=None)[source]¶ Record last play date of track (ie. not a real play history).
- Parameters
track (sima.lib.track.Track) – track to add to history
date (datetime.datetime) – UTC datetime object (use “datetime.now(timezone.utc)” is not set)
-
fetch_albums_history
(needle=None, duration=720)[source]¶ - Parameters
needle (sima.lib.meta.Artist) – When specified, returns albums history for this artist.
duration (int) – How long ago to fetch history from (in hours)
-
fetch_artists_history
(needle=None, duration=720)[source]¶ Returns a list of Artist objects
- Parameters
needle (sima.lib.meta.Artist or sima.lib.meta.MetaContainer) – When specified, returns history for these artists only
duration (int) – How long ago to fetch history from (in hours)
-
fetch_history
(artist=None, duration=720)[source]¶ Fetches tracks history, more recent first
- Parameters
artist (sima.lib.meta.Artist) – limit history to this artist
duration (int) – How long ago to fetch history from (in hours)
-
get_album
(album, with_connection=None, add=True)[source]¶ get album information from the database. if not in database insert new entry.
- Parameters
album (sima.lib.meta.Album) – album objet
with_connection (sqlite3.Connection) – SQLite connection
-
get_albumartist
(artist, with_connection=None, add=True)[source]¶ get albumartist information from the database. if not in database insert new entry.
- Parameters
artist (sima.lib.meta.Artist) – artist
with_connection (sqlite3.Connection) – SQLite connection
-
get_artist
(artist, with_connection=None, add=True)[source]¶ get artist information from the database. if not in database insert new entry.
- Parameters
artist (sima.lib.meta.Artist) – artist
with_connection (sqlite3.Connection) – SQLite connection
-
get_bl_album
(album, with_connection=None, add=True)[source]¶ Add an album to blocklist
- Parameters
sima.lib.meta.Album – Album object to add to blocklist
with_connection (sqlite3.Connection) – sqlite3.Connection to reuse, else create a new one
add (bool) – Default is to add a new record, set to False to fetch associated record
-
get_bl_artist
(artist, with_connection=None, add=True)[source]¶ Add an artist to blocklist
- Parameters
sima.lib.meta.Artist – Artist object to add to blocklist
with_connection (sqlite3.Connection) – sqlite3.Connection to reuse, else create a new one
add (bool) – Default is to add a new record, set to False to fetch associated record
-
get_bl_track
(track, with_connection=None, add=True)[source]¶ Add a track to blocklist
- Parameters
track (sima.lib.track.Track) – Track object to add to blocklist
with_connection (sqlite3.Connection) – sqlite3.Connection to reuse, else create a new one
add (bool) – Default is to add a new record, set to False to fetch associated record
-
get_genre
(genre, with_connection=None, add=True)[source]¶ get genre from the database. if not in database insert new entry.
- Parameters
genre (str) – genre as a string
with_connection (sqlite3.Connection) – SQLite connection
-
get_track
(track, with_connection=None, add=True)[source]¶ Get a track id from Tracks table, add if not existing,
- Parameters
track (sima.lib.track.Track) – track to use
add (bool) – add non existing track to database
-
-
sima.lib.simadb.
__HIST_DURATION__
= 720¶ Default history duration for both request and purge in hours