mmusicc.database package¶
mmusicc.database.metadb module¶
-
class
mmusicc.database.metadb.MetaDB(database_url)[source]¶ Bases:
objectObject representing a database connection in Metadata,
holds connection parameters and inserts and reads data. When writing to the Database, always all data is written, while you can load only select which tags to load. See https://docs.sqlalchemy.org/en/13/core/engines.html for Database Url examples.
There will be two tables. One only containing strings and string representation of objects and one containing the pickled strings or objects. This way all object types can be restored at loading while at the same time the database can be search with standard database queries.
Parameters: database_url (str) – database url following RFC-1738*. If the sting, does not contain ‘://’, a filepath for a sqlite database is assumed. -
database_url¶ Get URL of connected database.
-
insert_meta(dict_data, primary_key)[source]¶ Inserts a row into the database, with the values from the dict.
Parameters: - dict_data (dict) – metadata dictionary (Dict[str, object]) to be written.
- primary_key (str) – unique identifier of the item which data is to be written. Metadata uses the absolute filepath.
-
read_meta(primary_key, tags=None)[source]¶ returns values of a row with given primary key as metadata dict.
Parameters: - primary_key (str) – unique identifier of the item which data is to read (eg. Filepath).
- tags (list of str) – list of strings to be read, reads all if None. Defaults to None.
Returns: obj>): metadata dictionary
Return type: dict_data (dict<str
-