diff --git a/pyrekordbox/db6/database.py b/pyrekordbox/db6/database.py index a547e20..259c9b1 100644 --- a/pyrekordbox/db6/database.py +++ b/pyrekordbox/db6/database.py @@ -9,8 +9,9 @@ from pathlib import Path from typing import Optional from sqlalchemy import create_engine, or_, event, MetaData -from sqlalchemy.orm import sessionmaker, Session +from sqlalchemy.orm import Session from sqlalchemy.exc import NoResultFound +from sqlalchemy.sql.sqltypes import DateTime, String from packaging import version from ..utils import get_rekordbox_pid from ..config import get_config @@ -87,12 +88,12 @@ def open_rekordbox_database(path=None, key="", unlock=True, sql_driver=None): To use the ``pysqlcipher3`` package as SQLite driver, either import it as - >>> from pysqlcipher3 import dbapi2 as sqlite3 # noqa + >>> from sqlcipher3 import dbapi2 as sqlite3 # noqa >>> db = open_rekordbox_database("path/to/master_copy.db") or supply the package as driver: - >>> from pysqlcipher3 import dbapi2 + >>> from sqlcipher3 import dbapi2 # noqa >>> db = open_rekordbox_database("path/to/master_copy.db", sql_driver=dbapi2) """ if not path: @@ -231,7 +232,6 @@ def __init__(self, path=None, db_dir="", key="", unlock=True): raise FileNotFoundError(f"Database directory '{db_dir}' does not exist!") self.engine = engine - self._Session = sessionmaker(bind=self.engine) self.session: Optional[Session] = None self.registry = RekordboxAgentRegistry(self) @@ -272,7 +272,7 @@ def open(self): >>> db.open() """ if self.session is None: - self.session = self._Session() + self.session = Session(bind=self.engine) self.registry.clear_buffer() def close(self): @@ -1761,46 +1761,51 @@ def json_serial(obj): json.dump(data, fp, indent=indent, sort_keys=sort_keys, default=json_serial) def copy_unlocked(self, output_file): - src_metadata = MetaData(bind=self.engine) + src_engine = self.engine + src_metadata = MetaData() exclude_tables = ("sqlite_master", "sqlite_sequence", "sqlite_temp_master") dst_engine = create_engine(f"sqlite:///{output_file}") - dst_metadata = MetaData(bind=dst_engine) + dst_metadata = MetaData() @event.listens_for(src_metadata, "column_reflect") def genericize_datatypes(inspector, tablename, column_dict): - column_dict["type"] = column_dict["type"].as_generic(allow_nulltype=True) - - dst_engine.connect() - dst_metadata.reflect() - + type_ = column_dict["type"].as_generic(allow_nulltype=True) + if isinstance(type_, DateTime): + type_ = String + column_dict["type"] = type_ + + src_conn = src_engine.connect() + dst_conn = dst_engine.connect() + dst_metadata.reflect(bind=dst_engine) # drop all tables in target database for table in reversed(dst_metadata.sorted_tables): if table.name not in exclude_tables: print("dropping table =", table.name) - table.drop() - + table.drop(bind=dst_engine) + # # Delete all data in target database + # for table in reversed(dst_metadata.sorted_tables): + # table.delete() dst_metadata.clear() - dst_metadata.reflect() - src_metadata.reflect() - + dst_metadata.reflect(bind=dst_engine) + src_metadata.reflect(bind=src_engine) # create all tables in target database for table in src_metadata.sorted_tables: if table.name not in exclude_tables: table.create(bind=dst_engine) - # refresh metadata before you can copy data dst_metadata.clear() - dst_metadata.reflect() - + dst_metadata.reflect(bind=dst_engine) # Copy all data from src to target print("Copying data...") string = "\rCopying table {name}: Inserting row {row}" + index = 0 for table in dst_metadata.sorted_tables: src_table = src_metadata.tables[table.name] stmt = table.insert() - index = 0 - for index, row in enumerate(src_table.select().execute()): + for index, row in enumerate(src_conn.execute(src_table.select())): print(string.format(name=table.name, row=index), end="", flush=True) - stmt.execute(row._asdict()) # noqa + dst_conn.execute(stmt.values(row)) print(f"\rCopying table {table.name}: Inserted {index} rows", flush=True) + + dst_conn.commit() diff --git a/pyrekordbox/db6/tables.py b/pyrekordbox/db6/tables.py index 8f5ff7c..076ee82 100644 --- a/pyrekordbox/db6/tables.py +++ b/pyrekordbox/db6/tables.py @@ -4,9 +4,10 @@ """Rekordbox 6 `master.db` SQLAlchemy table declarations.""" -from sqlalchemy import Column, Integer, VARCHAR, BigInteger, SmallInteger, DateTime -from sqlalchemy import Text, ForeignKey, Float -from sqlalchemy.orm import declarative_base, relationship, backref +from datetime import datetime +from sqlalchemy import Column, Integer, VARCHAR, BigInteger, SmallInteger, Text, Float +from sqlalchemy import ForeignKey, TypeDecorator +from sqlalchemy.orm import DeclarativeBase, relationship, backref, mapped_column, Mapped from sqlalchemy.inspection import inspect from .registry import RekordboxAgentRegistry @@ -53,10 +54,29 @@ ] +class DateTime(TypeDecorator): + impl = Text + cache_ok = True + + def process_bind_param(self, value, dialect): + return value.isoformat().replace("T", " ")[:-3] + " +00:00" + + def process_result_value(self, value, dialect): + if value: + if len(value.strip()) > 23: + datestr, tzinfo = value[:23], value[23:] + datestr = datestr.strip() + tzinfo = tzinfo.strip() + assert tzinfo == "+00:00", tzinfo + else: + datestr, tzinfo = value, "" + return datetime.fromisoformat(datestr) + + # -- Base- and Mixin classes ----------------------------------------------------------- -class _Base(object): +class Base(DeclarativeBase): """Base class used to initialize the declarative base for all tables.""" __tablename__: str @@ -77,14 +97,14 @@ def columns(cls): @classmethod def relationships(cls): """Returns a list of all relationship names.""" - return [column.key for column in inspect(cls).relationships] + return [column.key for column in inspect(cls).relationships] # noqa def __iter__(self): """Iterates over all columns and relationship names.""" insp = inspect(self.__class__) for column in insp.c: yield column.name - for column in insp.relationships: + for column in insp.relationships: # noqa yield column.key def __len__(self): @@ -124,15 +144,12 @@ def pformat(self, indent=" "): return "\n".join(lines) -Base = declarative_base(cls=_Base) - - class StatsTime: """Mixin class for tables that only use time statistics columns.""" - created_at = Column(DateTime, nullable=False) + created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False) """The creation date of the table entry (from :class:`StatsTime`).""" - updated_at = Column(DateTime, nullable=False) + updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False) """The last update date of the table entry (from :class:`StatsTime`).""" @@ -142,24 +159,24 @@ class StatsFull: ID: Column """The ID (primary key) of the table entry.""" - UUID = Column(VARCHAR(255), default=None) + UUID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The UUID of the table entry (from :class:`StatsFull`)""" - rb_data_status = Column(Integer, default=0) + rb_data_status: Mapped[int] = mapped_column(Integer, default=0) """The data status of the table entry (from :class:`StatsFull`).""" - rb_local_data_status = Column(Integer, default=0) + rb_local_data_status: Mapped[int] = mapped_column(Integer, default=0) """The local data status of the table entry (from :class:`StatsFull`).""" - rb_local_deleted = Column(SmallInteger, default=0) + rb_local_deleted: Mapped[int] = mapped_column(SmallInteger, default=0) """The local deleted status of the table entry (from :class:`StatsFull`).""" - rb_local_synced = Column(SmallInteger, default=0) + rb_local_synced: Mapped[int] = mapped_column(SmallInteger, default=0) """The local synced status of the table entry (from :class:`StatsFull`).""" - usn = Column(BigInteger, default=None) + usn: Mapped[int] = mapped_column(BigInteger, default=None) """The USN (unique sequence number) of the table entry (from :class:`StatsFull`).""" - rb_local_usn = Column(BigInteger, default=None) + rb_local_usn: Mapped[int] = mapped_column(BigInteger, default=None) """The local USN (unique sequence number) of the table entry (from :class:`StatsFull`).""" - created_at = Column(DateTime, nullable=False) + created_at: Mapped[datetime] = mapped_column(DateTime, nullable=False) """The creation date of the table entry (from :class:`StatsFull`).""" - updated_at = Column(DateTime, nullable=False) + updated_at: Mapped[datetime] = mapped_column(DateTime, nullable=False) """The last update date of the table entry (from :class:`StatsFull`).""" def __repr__(self): @@ -183,27 +200,27 @@ class AgentRegistry(Base, StatsTime): __tablename__ = "agentRegistry" - registry_id = Column(VARCHAR(255), primary_key=True) + registry_id: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - id_1 = Column(VARCHAR(255), default=None) + id_1: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The first ID value of the table entry.""" - id_2 = Column(VARCHAR(255), default=None) + id_2: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The second ID value of the table entry.""" - int_1 = Column(Integer, default=None) + int_1: Mapped[int] = mapped_column(Integer, default=None) """The first integer value of the table entry.""" - int_2 = Column(Integer, default=None) + int_2: Mapped[int] = mapped_column(Integer, default=None) """The second integer value of the table entry.""" - str_1 = Column(VARCHAR(255), default=None) + str_1: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The first string value of the table entry.""" - str_2 = Column(VARCHAR(255), default=None) + str_2: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The second string value of the table entry.""" - date_1 = Column(DateTime, default=None) + date_1: Mapped[datetime] = mapped_column(DateTime, default=None) """The first date value of the table entry.""" - date_2 = Column(DateTime, default=None) + date_2: Mapped[datetime] = mapped_column(DateTime, default=None) """The second date value of the table entry.""" - text_1 = Column(Text, default=None) + text_1: Mapped[str] = mapped_column(Text, default=None) """The first text value of the table entry.""" - text_2 = Column(Text, default=None) + text_2: Mapped[str] = mapped_column(Text, default=None) """The second text value of the table entry.""" @@ -221,23 +238,23 @@ class CloudAgentRegistry(Base, StatsFull): __tablename__ = "cloudAgentRegistry" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - int_1 = Column(Integer, default=None) + int_1: Mapped[int] = mapped_column(Integer, default=None) """The first integer value of the table entry.""" - int_2 = Column(Integer, default=None) + int_2: Mapped[int] = mapped_column(Integer, default=None) """The second integer value of the table entry.""" - str_1 = Column(VARCHAR(255), default=None) + str_1: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The first string value of the table entry.""" - str_2 = Column(VARCHAR(255), default=None) + str_2: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The second string value of the table entry.""" - date_1 = Column(DateTime, default=None) + date_1: Mapped[datetime] = mapped_column(DateTime, default=None) """The first date value of the table entry.""" - date_2 = Column(DateTime, default=None) + date_2: Mapped[datetime] = mapped_column(DateTime, default=None) """The second date value of the table entry.""" - text_1 = Column(Text, default=None) + text_1: Mapped[str] = mapped_column(Text, default=None) """The first text value of the table entry.""" - text_2 = Column(Text, default=None) + text_2: Mapped[str] = mapped_column(Text, default=None) """The second text value of the table entry.""" @@ -251,13 +268,15 @@ class ContentActiveCensor(Base, StatsFull): __tablename__ = "contentActiveCensor" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the :class:`DjmdContent` entry this censor belongs to.""" - ActiveCensors = Column(Text, default=None) + ActiveCensors: Mapped[str] = mapped_column(Text, default=None) """The active censors of the table entry.""" - rb_activecensor_count = Column(Integer, default=None) + rb_activecensor_count: Mapped[int] = mapped_column(Integer, default=None) """The active censor count of the table entry.""" Content = relationship("DjmdContent") @@ -274,13 +293,15 @@ class ContentCue(Base, StatsFull): __tablename__ = "contentCue" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the :class:`DjmdContent` entry this cue belongs to.""" - Cues = Column(Text, default=None) + Cues: Mapped[str] = mapped_column(Text, default=None) """The cues of the table entry.""" - rb_cue_count = Column(Integer, default=None) + rb_cue_count: Mapped[int] = mapped_column(Integer, default=None) """The cue count of the table entry.""" Content = relationship("DjmdContent") @@ -297,35 +318,37 @@ class ContentFile(Base, StatsFull): __tablename__ = "contentFile" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the :class:`DjmdContent` entry this file belongs to.""" - Path = Column(VARCHAR(255), default=None) + Path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path of the file.""" - Hash = Column(VARCHAR(255), default=None) + Hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hash of the file.""" - Size = Column(Integer, default=None) + Size: Mapped[int] = mapped_column(Integer, default=None) """The size of the file.""" - rb_local_path = Column(VARCHAR(255), default=None) + rb_local_path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The local path of the file.""" - rb_insync_hash = Column(VARCHAR(255), default=None) + rb_insync_hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The in-sync hash of the file.""" - rb_insync_local_usn = Column(BigInteger, default=None) + rb_insync_local_usn: Mapped[int] = mapped_column(BigInteger, default=None) """The in-sync local USN (unique sequence number) of the file.""" - rb_file_hash_dirty = Column(Integer, default=0) + rb_file_hash_dirty: Mapped[int] = mapped_column(Integer, default=0) """The file hash dirty flag of the file.""" - rb_local_file_status = Column(Integer, default=0) + rb_local_file_status: Mapped[int] = mapped_column(Integer, default=0) """The local file status of the file.""" - rb_in_progress = Column(SmallInteger, default=0) + rb_in_progress: Mapped[int] = mapped_column(SmallInteger, default=0) """The in progress flag of the file.""" - rb_process_type = Column(Integer, default=0) + rb_process_type: Mapped[int] = mapped_column(Integer, default=0) """The process type of the file.""" - rb_temp_path = Column(VARCHAR(255), default=None) + rb_temp_path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The temporary path of the file.""" - rb_priority = Column(Integer, default=50) + rb_priority: Mapped[int] = mapped_column(Integer, default=50) """The priority of the file.""" - rb_file_size_dirty = Column(Integer, default=0) + rb_file_size_dirty: Mapped[int] = mapped_column(Integer, default=0) """The file size dirty flag of the file.""" Content = relationship("DjmdContent") @@ -342,19 +365,21 @@ class DjmdActiveCensor(Base, StatsFull): __tablename__ = "djmdActiveCensor" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the :class:`DjmdContent` entry this censor belongs to.""" - InMsec = Column(Integer, default=None) + InMsec: Mapped[int] = mapped_column(Integer, default=None) """The in time of the censor (in milliseconds).""" - OutMsec = Column(Integer, default=None) + OutMsec: Mapped[int] = mapped_column(Integer, default=None) """The out time of the censor (in milliseconds).""" - Info = Column(Integer, default=None) + Info: Mapped[int] = mapped_column(Integer, default=None) """Additional info of the censor.""" - ParameterList = Column(Text, default=None) + ParameterList: Mapped[str] = mapped_column(Text, default=None) """The parameter list of the censor.""" - ContentUUID = Column(VARCHAR(255), default=None) + ContentUUID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The UUID of the :class:`DjmdContent` entry this censor belongs to.""" Content = relationship("DjmdContent") @@ -371,17 +396,19 @@ class DjmdAlbum(Base, StatsFull): __tablename__ = "djmdAlbum" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the album.""" - AlbumArtistID = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + AlbumArtistID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the artist of this album.""" - ImagePath = Column(VARCHAR(255), default=None) + ImagePath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path of the image of the album.""" - Compilation = Column(Integer, default=None) + Compilation: Mapped[int] = mapped_column(Integer, default=None) """The compilation flag of the album.""" - SearchStr = Column(VARCHAR(255), default=None) + SearchStr: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The search string of the album.""" AlbumArtist = relationship("DjmdArtist") @@ -397,11 +424,11 @@ class DjmdArtist(Base, StatsFull): __tablename__ = "djmdArtist" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the artist.""" - SearchStr = Column(VARCHAR(255), default=None) + SearchStr: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The search string of the artist.""" def __repr__(self): @@ -419,18 +446,20 @@ class DjmdCategory(Base, StatsFull): __tablename__ = "djmdCategory" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - MenuItemID = Column(VARCHAR(255), ForeignKey("djmdMenuItems.ID"), default=None) + MenuItemID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdMenuItems.ID"), default=None + ) """The ID of the :class:`DjmdMenuItems` entry belonging to the category.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the category (for ordering).""" - Disable = Column(Integer, default=None) + Disable: Mapped[int] = mapped_column(Integer, default=None) """The disable flag of the category.""" - InfoOrder = Column(Integer, default=None) + InfoOrder: Mapped[int] = mapped_column(Integer, default=None) """Information for ordering the categories.""" - MenuItem = relationship("DjmdMenuItems", foreign_keys=[MenuItemID]) + MenuItem = relationship("DjmdMenuItems", foreign_keys=MenuItemID) """The menu item entry of the category (links to :class:`DjmdMenuItems`).""" @@ -439,13 +468,13 @@ class DjmdColor(Base, StatsFull): __tablename__ = "djmdColor" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ColorCode = Column(Integer, default=None) + ColorCode: Mapped[int] = mapped_column(Integer, default=None) """The color code of the color.""" - SortKey = Column(Integer, default=None) + SortKey: Mapped[int] = mapped_column(Integer, default=None) """The sort key of the color.""" - Commnt = Column(VARCHAR(255), default=None) + Commnt: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The comment (name) of the color.""" def __repr__(self): @@ -472,162 +501,182 @@ class DjmdContent(Base, StatsFull): __tablename__ = "djmdContent" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the track.""" - FolderPath = Column(VARCHAR(255), default=None) + FolderPath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The full path of the file corresponding to the content entry.""" - FileNameL = Column(VARCHAR(255), default=None) + FileNameL: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The long file name of the file corresponding to the content entry.""" - FileNameS = Column(VARCHAR(255), default=None) + FileNameS: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The short file name of the file corresponding to the content entry.""" - Title = Column(VARCHAR(255), default=None) + Title: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The title of the track.""" - ArtistID = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + ArtistID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the artist of this track.""" - AlbumID = Column(VARCHAR(255), ForeignKey("djmdAlbum.ID"), default=None) + AlbumID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdAlbum.ID"), default=None + ) """The ID of the :class:`DjmdAlbum` entry of the album of this track.""" - GenreID = Column(VARCHAR(255), ForeignKey("djmdGenre.ID"), default=None) + GenreID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdGenre.ID"), default=None + ) """The ID of the :class:`DjmdGenre` entry of the genre of this track.""" - BPM = Column(Integer, default=None) + BPM: Mapped[int] = mapped_column(Integer, default=None) """The BPM (beats per minute) of the track.""" - Length = Column(Integer, default=None) + Length: Mapped[int] = mapped_column(Integer, default=None) """The length of the track.""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the track.""" - BitRate = Column(Integer, default=None) + BitRate: Mapped[int] = mapped_column(Integer, default=None) """The bit rate of the track.""" - BitDepth = Column(Integer, default=None) + BitDepth: Mapped[int] = mapped_column(Integer, default=None) """The bit depth of the track.""" - Commnt = Column(Text, default=None) + Commnt: Mapped[str] = mapped_column(Text, default=None) """The comment of the track.""" - FileType = Column(Integer, default=None) + FileType: Mapped[int] = mapped_column(Integer, default=None) """The file type of the track.""" - Rating = Column(Integer, default=None) + Rating: Mapped[int] = mapped_column(Integer, default=None) """The rating of the track.""" - ReleaseYear = Column(Integer, default=None) + ReleaseYear: Mapped[int] = mapped_column(Integer, default=None) """The release year of the track.""" - RemixerID = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + RemixerID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the remixer of this track.""" - LabelID = Column(VARCHAR(255), ForeignKey("djmdLabel.ID"), default=None) + LabelID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdLabel.ID"), default=None + ) """The ID of the :class:`DjmdLabel` entry of the label of this track.""" - OrgArtistID = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + OrgArtistID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the original artist of this track.""" - KeyID = Column(VARCHAR(255), ForeignKey("djmdKey.ID"), default=None) + KeyID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdKey.ID"), default=None + ) """The ID of the :class:`DjmdKey` entry of the key of this track.""" - StockDate = Column(VARCHAR(255), default=None) + StockDate: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The stock date of the track.""" - ColorID = Column(VARCHAR(255), ForeignKey("djmdColor.ID"), default=None) + ColorID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdColor.ID"), default=None + ) """The ID of the :class:`DjmdColor` entry of the color of this track.""" - DJPlayCount = Column(VARCHAR(255), default=None) + DJPlayCount: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The play count of the track.""" - ImagePath = Column(VARCHAR(255), default=None) + ImagePath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path of the image of the track.""" - MasterDBID = Column(VARCHAR(255), default=None) + MasterDBID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The master database ID of the track.""" - MasterSongID = Column(VARCHAR(255), default=None) + MasterSongID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The master song ID of the track.""" - AnalysisDataPath = Column(VARCHAR(255), default=None) + AnalysisDataPath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path of the analysis data (ANLZ) of the track.""" - SearchStr = Column(VARCHAR(255), default=None) + SearchStr: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The search string of the track.""" - FileSize = Column(Integer, default=None) + FileSize: Mapped[int] = mapped_column(Integer, default=None) """The file size of the track.""" - DiscNo = Column(Integer, default=None) + DiscNo: Mapped[int] = mapped_column(Integer, default=None) """The number of the disc of the album of the track.""" - ComposerID = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + ComposerID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the composer of this track.""" - Subtitle = Column(VARCHAR(255), default=None) + Subtitle: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The subtitle of the track.""" - SampleRate = Column(Integer, default=None) + SampleRate: Mapped[int] = mapped_column(Integer, default=None) """The sample rate of the track in Hz.""" - DisableQuantize = Column(Integer, default=None) + DisableQuantize: Mapped[int] = mapped_column(Integer, default=None) """Individual quantize status of the track.""" - Analysed = Column(Integer, default=None) + Analysed: Mapped[int] = mapped_column(Integer, default=None) """The analysis status of the track.""" - ReleaseDate = Column(VARCHAR(255), default=None) + ReleaseDate: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The release date of the track.""" - DateCreated = Column(VARCHAR(255), default=None) + DateCreated: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The date the track was created.""" - ContentLink = Column(Integer, default=None) + ContentLink: Mapped[int] = mapped_column(Integer, default=None) """The content link of the track.""" - Tag = Column(VARCHAR(255), default=None) + Tag: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The tag of the track.""" - ModifiedByRBM = Column(VARCHAR(255), default=None) + ModifiedByRBM: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The modified by RBM status of the track.""" - HotCueAutoLoad = Column(VARCHAR(255), default=None) + HotCueAutoLoad: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hot cue auto load status of the track.""" - DeliveryControl = Column(VARCHAR(255), default=None) + DeliveryControl: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The delivery control status of the track.""" - DeliveryComment = Column(VARCHAR(255), default=None) + DeliveryComment: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The delivery comment of the track.""" - CueUpdated = Column(VARCHAR(255), default=None) + CueUpdated: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The cue updated status of the track.""" - AnalysisUpdated = Column(VARCHAR(255), default=None) + AnalysisUpdated: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The analysis updated status of the track.""" - TrackInfoUpdated = Column(VARCHAR(255), default=None) + TrackInfoUpdated: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The track info updated status of the track.""" - Lyricist = Column(VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None) + Lyricist: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdArtist.ID"), default=None + ) """The ID of the :class:`DjmdArtist` entry of the lyricist of this track.""" - ISRC = Column(VARCHAR(255), default=None) + ISRC: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ISRC of the track.""" - SamplerTrackInfo = Column(Integer, default=None) + SamplerTrackInfo: Mapped[int] = mapped_column(Integer, default=None) """The sampler track info of the track.""" - SamplerPlayOffset = Column(Integer, default=None) + SamplerPlayOffset: Mapped[int] = mapped_column(Integer, default=None) """The sampler play offset of the track.""" - SamplerGain = Column(Float, default=None) + SamplerGain: Mapped[float] = mapped_column(Float, default=None) """The sampler gain of the track.""" - VideoAssociate = Column(VARCHAR(255), default=None) + VideoAssociate: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The video associate of the track.""" - LyricStatus = Column(Integer, default=None) + LyricStatus: Mapped[int] = mapped_column(Integer, default=None) """The lyric status of the track.""" - ServiceID = Column(Integer, default=None) + ServiceID: Mapped[int] = mapped_column(Integer, default=None) """The service ID of the track.""" - OrgFolderPath = Column(VARCHAR(255), default=None) + OrgFolderPath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The original folder path of the track.""" - Reserved1 = Column(Text, default=None) + Reserved1: Mapped[str] = mapped_column(Text, default=None) """Reserved field 1.""" - Reserved2 = Column(Text, default=None) + Reserved2: Mapped[str] = mapped_column(Text, default=None) """Reserved field 2.""" - Reserved3 = Column(Text, default=None) + Reserved3: Mapped[str] = mapped_column(Text, default=None) """Reserved field 3.""" - Reserved4 = Column(Text, default=None) + Reserved4: Mapped[str] = mapped_column(Text, default=None) """Reserved field 4.""" - ExtInfo = Column(Text, default=None) + ExtInfo: Mapped[str] = mapped_column(Text, default=None) """The extended information of the track.""" - rb_file_id = Column(VARCHAR(255), default=None) + rb_file_id: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The file ID used by Rekordbox of the track.""" - DeviceID = Column(VARCHAR(255), default=None) + DeviceID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The device ID of the track.""" - rb_LocalFolderPath = Column(VARCHAR(255), default=None) + rb_LocalFolderPath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The local folder path used by Rekordbox of the track.""" - SrcID = Column(VARCHAR(255), default=None) + SrcID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the source of the track.""" - SrcTitle = Column(VARCHAR(255), default=None) + SrcTitle: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The title of the source of the track.""" - SrcArtistName = Column(VARCHAR(255), default=None) + SrcArtistName: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The artist name of the source of the track.""" - SrcAlbumName = Column(VARCHAR(255), default=None) + SrcAlbumName: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The album name of the source of the track.""" - SrcLength = Column(Integer, default=None) + SrcLength: Mapped[int] = mapped_column(Integer, default=None) """The length of the source of the track.""" - Artist = relationship("DjmdArtist", foreign_keys=[ArtistID]) + Artist = relationship("DjmdArtist", foreign_keys=ArtistID) """The artist entry of the track (links to :class:`DjmdArtists`).""" - Album = relationship("DjmdAlbum", foreign_keys=[AlbumID]) + Album = relationship("DjmdAlbum", foreign_keys=AlbumID) """The album entry of the track (links to :class:`DjmdAlbum`).""" - Genre = relationship("DjmdGenre", foreign_keys=[GenreID]) + Genre = relationship("DjmdGenre", foreign_keys=GenreID) """The genre entry of the track (links to :class:`DjmdGenre`).""" - Remixer = relationship("DjmdArtist", foreign_keys=[RemixerID]) + Remixer = relationship("DjmdArtist", foreign_keys=RemixerID) """The remixer entry of the track (links to :class:`DjmdArtist`).""" - Label = relationship("DjmdLabel", foreign_keys=[LabelID]) + Label = relationship("DjmdLabel", foreign_keys=LabelID) """The label entry of the track (links to :class:`DjmdLabel`).""" - OrgArtist = relationship("DjmdArtist", foreign_keys=[OrgArtistID]) + OrgArtist = relationship("DjmdArtist", foreign_keys=OrgArtistID) """The original artist entry of the track (links to :class:`DjmdArtist`).""" - Key = relationship("DjmdKey", foreign_keys=[KeyID]) + Key = relationship("DjmdKey", foreign_keys=KeyID) """The key entry of the track (links to :class:`DjmdKey`).""" - Color = relationship("DjmdColor", foreign_keys=[ColorID]) + Color = relationship("DjmdColor", foreign_keys=ColorID) """The color entry of the track (links to :class:`DjmdColor`).""" - Composer = relationship("DjmdArtist", foreign_keys=[ComposerID]) + Composer = relationship("DjmdArtist", foreign_keys=ComposerID) """The composer entry of the track (links to :class:`DjmdArtist`).""" def __repr__(self): @@ -717,48 +766,52 @@ class DjmdCue(Base, StatsFull): __tablename__ = "djmdCue" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content (:class:`DjmdContent`) containing the cue point.""" - InMsec = Column(Integer, default=None) + InMsec: Mapped[int] = mapped_column(Integer, default=None) """The in point of the cue point in milliseconds.""" - InFrame = Column(Integer, default=None) + InFrame: Mapped[int] = mapped_column(Integer, default=None) """The in point of the cue point in frames.""" - InMpegFrame = Column(Integer, default=None) + InMpegFrame: Mapped[int] = mapped_column(Integer, default=None) """The in point of the cue point in MPEG frames.""" - InMpegAbs = Column(Integer, default=None) + InMpegAbs: Mapped[int] = mapped_column(Integer, default=None) """The in point of the cue point in MPEG absolute.""" - OutMsec = Column(Integer, default=None) + OutMsec: Mapped[int] = mapped_column(Integer, default=None) """The out point of the cue point in milliseconds (for loops).""" - OutFrame = Column(Integer, default=None) + OutFrame: Mapped[int] = mapped_column(Integer, default=None) """The out point of the cue point in frames (for loops).""" - OutMpegFrame = Column(Integer, default=None) + OutMpegFrame: Mapped[int] = mapped_column(Integer, default=None) """The out point of the cue point in MPEG frames (for loops).""" - OutMpegAbs = Column(Integer, default=None) + OutMpegAbs: Mapped[int] = mapped_column(Integer, default=None) """The out point of the cue point in MPEG absolute (for loops).""" - Kind = Column(Integer, default=None) + Kind: Mapped[int] = mapped_column(Integer, default=None) """The kind of the cue point (Cue=0, Fade-In=0, Fade-Out=0, Load=3, Loop=4).""" - Color = Column(Integer, default=None) + Color: Mapped[int] = mapped_column(Integer, default=None) """The color of the cue point. (-1 if no color)""" - ColorTableIndex = Column(Integer, default=None) + ColorTableIndex: Mapped[int] = mapped_column(Integer, default=None) """The color table index of the cue point.""" - ActiveLoop = Column(Integer, default=None) + ActiveLoop: Mapped[int] = mapped_column(Integer, default=None) """The active loop of the cue point.""" - Comment = Column(VARCHAR(255), default=None) + Comment: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The comment of the cue point.""" - BeatLoopSize = Column(Integer, default=None) + BeatLoopSize: Mapped[int] = mapped_column(Integer, default=None) """The beat loop size of the cue point.""" - CueMicrosec = Column(Integer, default=None) + CueMicrosec: Mapped[int] = mapped_column(Integer, default=None) """The cue microsecond of the cue point.""" - InPointSeekInfo = Column(VARCHAR(255), default=None) + InPointSeekInfo: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The in point seek info of the cue point.""" - OutPointSeekInfo = Column(VARCHAR(255), default=None) + OutPointSeekInfo: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The out point seek info of the cue point.""" - ContentUUID = Column(VARCHAR(255), ForeignKey("djmdContent.UUID"), default=None) + ContentUUID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.UUID"), default=None + ) """The UUID of the content (:class:`DjmdContent`) containing the cue point.""" - Content = relationship("DjmdContent", foreign_keys=[ContentID]) + Content = relationship("DjmdContent", foreign_keys=ContentID) """The content entry of the cue point (links to :class:`DjmdContent`).""" @@ -767,11 +820,11 @@ class DjmdDevice(Base, StatsFull): __tablename__ = "djmdDevice" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - MasterDBID = Column(VARCHAR(255), default=None) + MasterDBID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the master database.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the device.""" def __repr__(self): @@ -784,9 +837,9 @@ class DjmdGenre(Base, StatsFull): __tablename__ = "djmdGenre" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the genre.""" def __repr__(self): @@ -804,17 +857,19 @@ class DjmdHistory(Base, StatsFull): __tablename__ = "djmdHistory" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry (:class:`DjmdHistory`).""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the history playlist (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the history playlist.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attributes of the history playlist""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdHistory.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdHistory.ID"), default=None + ) """The ID of the parent history playlist (:class:`DjmdHistory`).""" - DateCreated = Column(VARCHAR(255), default=None) + DateCreated: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The date the history playlist was created.""" Songs = relationship("DjmdSongHistory", back_populates="History") @@ -843,13 +898,17 @@ class DjmdSongHistory(Base, StatsFull): __tablename__ = "djmdSongHistory" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) - HistoryID = Column(VARCHAR(255), ForeignKey("djmdHistory.ID"), default=None) + HistoryID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdHistory.ID"), default=None + ) """The ID of the history playlist (:class:`DjmdHistory`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the song in the history playlist.""" History = relationship("DjmdHistory", back_populates="Songs") @@ -868,17 +927,19 @@ class DjmdHotCueBanklist(Base, StatsFull): __tablename__ = "djmdHotCueBanklist" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry (:class:`DjmdHotCueBanklist`)""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the hot-cue banklist (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the hot-cue banklist.""" - ImagePath = Column(VARCHAR(255), default=None) + ImagePath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path to the image of the hot-cue banklist.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attributes of the hot cue banklist.""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdHotCueBanklist.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdHotCueBanklist.ID"), default=None + ) """The ID of the parent hot-cue banklist (:class:`DjmdHotCueBanklist`).""" Children = relationship( @@ -905,51 +966,53 @@ class DjmdSongHotCueBanklist(Base, StatsFull): __tablename__ = "djmdSongHotCueBanklist" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - HotCueBanklistID = Column( + HotCueBanklistID: Mapped[str] = mapped_column( VARCHAR(255), ForeignKey("djmdHotCueBanklist.ID"), default=None ) """The ID of the hot cue banklist (:class:`DjmdHotCueBanklist`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the hot-cue in the hot cue banklist.""" - CueID = Column(VARCHAR(255), default=None) + CueID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the hot-cue.""" - InMsec = Column(Integer, default=None) + InMsec: Mapped[int] = mapped_column(Integer, default=None) """The in point of the hot-cue in milliseconds.""" - InFrame = Column(Integer, default=None) + InFrame: Mapped[int] = mapped_column(Integer, default=None) """The in point of the hot-cue in frames.""" - InMpegFrame = Column(Integer, default=None) + InMpegFrame: Mapped[int] = mapped_column(Integer, default=None) """The in point of the hot-cue in MPEG frames.""" - InMpegAbs = Column(Integer, default=None) + InMpegAbs: Mapped[int] = mapped_column(Integer, default=None) """The in point of the hot-cue in MPEG absolute.""" - OutMsec = Column(Integer, default=None) + OutMsec: Mapped[int] = mapped_column(Integer, default=None) """The out point of the hot-cue in milliseconds (for loops).""" - OutFrame = Column(Integer, default=None) + OutFrame: Mapped[int] = mapped_column(Integer, default=None) """The out point of the hot-cue in frames (for loops).""" - OutMpegFrame = Column(Integer, default=None) + OutMpegFrame: Mapped[int] = mapped_column(Integer, default=None) """The out point of the hot-cue in MPEG frames (for loops).""" - OutMpegAbs = Column(Integer, default=None) + OutMpegAbs: Mapped[int] = mapped_column(Integer, default=None) """The out point of the hot-cue in MPEG absolute (for loops).""" - Color = Column(Integer, default=None) + Color: Mapped[int] = mapped_column(Integer, default=None) """The color of the hot-cue.""" - ColorTableIndex = Column(Integer, default=None) + ColorTableIndex: Mapped[int] = mapped_column(Integer, default=None) """The color table index of the hot-cue.""" - ActiveLoop = Column(Integer, default=None) + ActiveLoop: Mapped[int] = mapped_column(Integer, default=None) """The active loop flag of the hot-cue.""" - Comment = Column(VARCHAR(255), default=None) + Comment: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The comment of the hot-cue.""" - BeatLoopSize = Column(Integer, default=None) + BeatLoopSize: Mapped[int] = mapped_column(Integer, default=None) """The beat loop size of the hot-cue.""" - CueMicrosec = Column(Integer, default=None) + CueMicrosec: Mapped[int] = mapped_column(Integer, default=None) """The cue microsecond of the hot-cue.""" - InPointSeekInfo = Column(VARCHAR(255), default=None) + InPointSeekInfo: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The in point seek info of the hot-cue.""" - OutPointSeekInfo = Column(VARCHAR(255), default=None) + OutPointSeekInfo: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The out point seek info of the hot-cue.""" - HotCueBanklistUUID = Column( + HotCueBanklistUUID: Mapped[str] = mapped_column( VARCHAR(255), ForeignKey("djmdHotCueBanklist.UUID"), default=None ) """The UUID of the hot-cue banklist (links to :class:`DjmdHotCueBanklist`).""" @@ -963,11 +1026,11 @@ class DjmdKey(Base, StatsFull): __tablename__ = "djmdKey" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ScaleName = Column(VARCHAR(255), default=None) + ScaleName: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The scale (name) of the key.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the key (for ordering).""" def __repr__(self): @@ -980,9 +1043,9 @@ class DjmdLabel(Base, StatsFull): __tablename__ = "djmdLabel" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the label.""" def __repr__(self): @@ -995,11 +1058,11 @@ class DjmdMenuItems(Base, StatsFull): __tablename__ = "djmdMenuItems" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Class = Column(Integer, default=None) + Class: Mapped[int] = mapped_column(Integer, default=None) """The class of the menu item.""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the menu item.""" def __repr__(self): @@ -1017,17 +1080,19 @@ class DjmdMixerParam(Base, StatsFull): __tablename__ = "djmdMixerParam" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content (:class:`DjmdContent`).""" - GainHigh = Column(Integer, default=None) + GainHigh: Mapped[int] = mapped_column(Integer, default=None) """The high gain of the mixer parameter.""" - GainLow = Column(Integer, default=None) + GainLow: Mapped[int] = mapped_column(Integer, default=None) """The low gain of the mixer parameter.""" - PeakHigh = Column(Integer, default=None) + PeakHigh: Mapped[int] = mapped_column(Integer, default=None) """The high peak of the mixer parameter.""" - PeakLow = Column(Integer, default=None) + PeakLow: Mapped[int] = mapped_column(Integer, default=None) """The low peak of the mixer parameter.""" Content = relationship("DjmdContent") @@ -1044,15 +1109,19 @@ class DjmdMyTag(Base, StatsFull): __tablename__ = "djmdMyTag" - ID = Column(VARCHAR(255), ForeignKey("djmdMyTag.ParentID"), primary_key=True) + ID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdMyTag.ParentID"), primary_key=True + ) """The ID (primary key) of the table entry.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the My-Tag list (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the My-Tag list.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attribute of the My-Tag list.""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdMyTag.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdMyTag.ID"), default=None + ) """The ID of the parent My-Tag list (:class:`DjmdMyTag`).""" MyTags = relationship("DjmdSongMyTag", back_populates="MyTag") @@ -1079,13 +1148,17 @@ class DjmdSongMyTag(Base, StatsFull): __tablename__ = "djmdSongMyTag" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - MyTagID = Column(VARCHAR(255), ForeignKey("djmdMyTag.ID"), default=None) + MyTagID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdMyTag.ID"), default=None + ) """The ID of the My-Tag list (links to :class:`DjmdMyTag`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content this item belongs to (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the My-Tag item (for ordering).""" MyTag = relationship("DjmdMyTag", back_populates="MyTags") @@ -1104,19 +1177,21 @@ class DjmdPlaylist(Base, StatsFull): __tablename__ = "djmdPlaylist" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the playlist (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the playlist.""" - ImagePath = Column(VARCHAR(255), default=None) + ImagePath: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path to the image of the playlist.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attribute of the playlist.""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdPlaylist.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdPlaylist.ID"), default=None + ) """The ID of the parent playlist (:class:`DjmdPlaylist`).""" - SmartList = Column(Text, default=None) + SmartList: Mapped[str] = mapped_column(Text, default=None) """The smart list settings of the playlist.""" Songs = relationship( @@ -1148,13 +1223,17 @@ class DjmdSongPlaylist(Base, StatsFull): __tablename__ = "djmdSongPlaylist" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - PlaylistID = Column(VARCHAR(255), ForeignKey("djmdPlaylist.ID"), default=None) + PlaylistID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdPlaylist.ID"), default=None + ) """The ID of the playlist this item is in (:class:`DjmdPlaylist`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content this item belongs to (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the playlist item (for ordering).""" Playlist = relationship("DjmdPlaylist", back_populates="Songs") @@ -1173,17 +1252,19 @@ class DjmdRelatedTracks(Base, StatsFull): __tablename__ = "djmdRelatedTracks" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the related tracks list (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the related tracks list.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attribute of the related tracks list.""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdRelatedTracks.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdRelatedTracks.ID"), default=None + ) """The ID of the parent related tracks list (:class:`DjmdRelatedTracks`).""" - Criteria = Column(Text, default=None) + Criteria: Mapped[str] = mapped_column(Text, default=None) """The criteria used to determine the items in the related tracks list.""" Songs = relationship("DjmdSongRelatedTracks", back_populates="RelatedTracks") @@ -1214,16 +1295,18 @@ class DjmdSongRelatedTracks(Base, StatsFull): __tablename__ = "djmdSongRelatedTracks" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - RelatedTracksID = Column( + RelatedTracksID: Mapped[str] = mapped_column( VARCHAR(255), ForeignKey("djmdRelatedTracks.ID"), default=None ) """The ID of the related tracks list this item is in (:class:`DjmdRelatedTracks`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content this item belongs to (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the related tracks list item (for ordering).""" RelatedTracks = relationship("DjmdRelatedTracks", back_populates="Songs") @@ -1242,15 +1325,17 @@ class DjmdSampler(Base, StatsFull): __tablename__ = "djmdSampler" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the sampler list (for ordering).""" - Name = Column(VARCHAR(255), default=None) + Name: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the sampler list.""" - Attribute = Column(Integer, default=None) + Attribute: Mapped[int] = mapped_column(Integer, default=None) """The attribute of the sampler list.""" - ParentID = Column(VARCHAR(255), ForeignKey("djmdSampler.ID"), default=None) + ParentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdSampler.ID"), default=None + ) """The ID of the parent sampler list (:class:`DjmdSampler`).""" Songs = relationship("DjmdSongSampler", back_populates="Sampler") @@ -1279,13 +1364,17 @@ class DjmdSongSampler(Base, StatsFull): __tablename__ = "djmdSongSampler" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - SamplerID = Column(VARCHAR(255), ForeignKey("djmdSampler.ID"), default=None) + SamplerID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdSampler.ID"), default=None + ) """The ID of the sampler list this item is in (:class:`DjmdSampler`).""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content this item belongs to (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the sampler list item (for ordering).""" Sampler = relationship("DjmdSampler", back_populates="Songs") @@ -1299,11 +1388,13 @@ class DjmdSongTagList(Base, StatsFull): __tablename__ = "djmdSongTagList" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - ContentID = Column(VARCHAR(255), ForeignKey("djmdContent.ID"), default=None) + ContentID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdContent.ID"), default=None + ) """The ID of the content this item belongs to (:class:`DjmdContent`).""" - TrackNo = Column(Integer, default=None) + TrackNo: Mapped[int] = mapped_column(Integer, default=None) """The track number of the tag list item (for ordering).""" Content = relationship("DjmdContent") @@ -1320,16 +1411,18 @@ class DjmdSort(Base, StatsFull): __tablename__ = "djmdSort" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - MenuItemID = Column(VARCHAR(255), ForeignKey("djmdMenuItems.ID"), default=None) + MenuItemID: Mapped[str] = mapped_column( + VARCHAR(255), ForeignKey("djmdMenuItems.ID"), default=None + ) """The ID of the menu item this sort list is in (:class:`DjmdMenuItems`).""" - Seq = Column(Integer, default=None) + Seq: Mapped[int] = mapped_column(Integer, default=None) """The sequence of the sort list (for ordering).""" - Disable = Column(Integer, default=None) + Disable: Mapped[int] = mapped_column(Integer, default=None) """Whether the sort list is disabled.""" - MenuItem = relationship("DjmdMenuItems", foreign_keys=[MenuItemID]) + MenuItem = relationship("DjmdMenuItems", foreign_keys=MenuItemID) """The menu item this sort list is in (links to :class:`DjmdMenuItems`).""" @@ -1338,13 +1431,13 @@ class HotCueBanklistCue(Base, StatsFull): __tablename__ = "hotCueBanklistCue" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - HotCueBanklistID = Column(VARCHAR(255), default=None) + HotCueBanklistID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the hot cue bank list.""" - Cues = Column(Text, default=None) + Cues: Mapped[str] = mapped_column(Text, default=None) """The hot cue bank list contents.""" - rb_cue_count = Column(Integer, default=None) + rb_cue_count: Mapped[int] = mapped_column(Integer, default=None) """The number of hot cues in the bank list.""" @@ -1353,25 +1446,25 @@ class DjmdProperty(Base, StatsTime): __tablename__ = "djmdProperty" - DBID = Column(VARCHAR(255), primary_key=True) + DBID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - DBVersion = Column(VARCHAR(255), default=None) + DBVersion: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The version of the database.""" - BaseDBDrive = Column(VARCHAR(255), default=None) + BaseDBDrive: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The drive the database is stored on.""" - CurrentDBDrive = Column(VARCHAR(255), default=None) + CurrentDBDrive: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The drive the database is currently stored on.""" - DeviceID = Column(VARCHAR(255), default=None) + DeviceID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the device the database is stored on.""" - Reserved1 = Column(Text, default=None) + Reserved1: Mapped[str] = mapped_column(Text, default=None) """Reserved column.""" - Reserved2 = Column(Text, default=None) + Reserved2: Mapped[str] = mapped_column(Text, default=None) """Reserved column.""" - Reserved3 = Column(Text, default=None) + Reserved3: Mapped[str] = mapped_column(Text, default=None) """Reserved column.""" - Reserved4 = Column(Text, default=None) + Reserved4: Mapped[str] = mapped_column(Text, default=None) """Reserved column.""" - Reserved5 = Column(Text, default=None) + Reserved5: Mapped[str] = mapped_column(Text, default=None) """Reserved column.""" @@ -1380,39 +1473,39 @@ class ImageFile(Base, StatsFull): __tablename__ = "imageFile" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - TableName = Column(VARCHAR(255), default=None) + TableName: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the table the image file is in.""" - TargetUUID = Column(VARCHAR(255), default=None) + TargetUUID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The UUID of the target the image file is for.""" - TargetID = Column(VARCHAR(255), default=None) + TargetID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the target the image file is for.""" - Path = Column(VARCHAR(255), default=None) + Path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path to the image file.""" - Hash = Column(VARCHAR(255), default=None) + Hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hash of the image file.""" - Size = Column(Integer, default=None) + Size: Mapped[int] = mapped_column(Integer, default=None) """The size of the image file.""" - rb_local_path = Column(VARCHAR(255), default=None) + rb_local_path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The local path to the image file.""" - rb_insync_hash = Column(VARCHAR(255), default=None) + rb_insync_hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hash of the image file.""" - rb_insync_local_usn = Column(BigInteger, default=None) + rb_insync_local_usn: Mapped[int] = mapped_column(BigInteger, default=None) """The local USN of the in-sync image file.""" - rb_file_hash_dirty = Column(Integer, default=0) + rb_file_hash_dirty: Mapped[int] = mapped_column(Integer, default=0) """Whether the hash of the image file is dirty.""" - rb_local_file_status = Column(Integer, default=0) + rb_local_file_status: Mapped[int] = mapped_column(Integer, default=0) """The status of the image file.""" - rb_in_progress = Column(SmallInteger, default=0) + rb_in_progress: Mapped[int] = mapped_column(SmallInteger, default=0) """Whether the image file is in progress.""" - rb_process_type = Column(Integer, default=0) + rb_process_type: Mapped[int] = mapped_column(Integer, default=0) """The type of process the image file is in.""" - rb_temp_path = Column(VARCHAR(255), default=None) + rb_temp_path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The temporary path of the image file.""" - rb_priority = Column(Integer, default=50) + rb_priority: Mapped[int] = mapped_column(Integer, default=50) """The priority of the image file.""" - rb_file_size_dirty = Column(Integer, default=0) + rb_file_size_dirty: Mapped[int] = mapped_column(Integer, default=0) """Whether the size of the image file is dirty.""" @@ -1421,23 +1514,23 @@ class SettingFile(Base, StatsFull): __tablename__ = "settingFile" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - Path = Column(VARCHAR(255), default=None) + Path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The path to the setting file.""" - Hash = Column(VARCHAR(255), default=None) + Hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hash of the setting file.""" - Size = Column(Integer, default=None) + Size: Mapped[int] = mapped_column(Integer, default=None) """The size of the setting file.""" - rb_local_path = Column(VARCHAR(255), default=None) + rb_local_path: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The local path to the setting file.""" - rb_insync_hash = Column(VARCHAR(255), default=None) + rb_insync_hash: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The hash of the in-sync setting file.""" - rb_insync_local_usn = Column(BigInteger, default=None) + rb_insync_local_usn: Mapped[int] = mapped_column(BigInteger, default=None) """The local USN of the setting file.""" - rb_file_hash_dirty = Column(Integer, default=0) + rb_file_hash_dirty: Mapped[int] = mapped_column(Integer, default=0) """Whether the hash of the setting file is dirty.""" - rb_file_size_dirty = Column(Integer, default=0) + rb_file_size_dirty: Mapped[int] = mapped_column(Integer, default=0) """Whether the size of the setting file is dirty.""" @@ -1446,11 +1539,11 @@ class UuidIDMap(Base, StatsFull): __tablename__ = "uuidIDMap" - ID = Column(VARCHAR(255), primary_key=True) + ID: Mapped[str] = mapped_column(VARCHAR(255), primary_key=True) """The ID (primary key) of the table entry.""" - TableName = Column(VARCHAR(255), default=None) + TableName: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The name of the table the mapping is used for.""" - TargetUUID = Column(VARCHAR(255), default=None) + TargetUUID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The UUID of the mapping.""" - CurrentID = Column(VARCHAR(255), default=None) + CurrentID: Mapped[str] = mapped_column(VARCHAR(255), default=None) """The ID of the mapping.""" diff --git a/requirements.txt b/requirements.txt index 8d70129..04604c3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,4 @@ pytest>=6.2.0 psutil>=5.9.0 setuptools>=60.0.0 setuptools-scm[toml]>=4 -sqlalchemy~=1.4.0 +sqlalchemy>=2.0.0