models.py 1.69 KB
Newer Older
Lukáš Lalinský's avatar
Lukáš Lalinský committed
1
from typing import Any
Lukáš Lalinský's avatar
Lukáš Lalinský committed
2
from sqlalchemy.orm import relationship
3
from sqlalchemy.ext.declarative import declarative_base
4 5
from acoustid import tables

Lukáš Lalinský's avatar
Lukáš Lalinský committed
6
Base = declarative_base(metadata=tables.metadata)  # type: Any
7 8


9 10
class Account(Base):
    __table__ = tables.account
11 12


Lukáš Lalinský's avatar
Lukáš Lalinský committed
13 14 15 16 17 18 19 20 21 22 23 24
class AccountOpenID(Base):
    __table__ = tables.account_openid

    account = relationship('Account')


class AccountGoogle(Base):
    __table__ = tables.account_google

    account = relationship('Account')


25 26
class Application(Base):
    __table__ = tables.application
27

28
    account = relationship('Account', foreign_keys=[tables.application.c.account_id])
29 30


31 32
class TrackMBID(Base):
    __table__ = tables.track_mbid
33

34
    track = relationship('Track')
35 36


37 38
class TrackMBIDChange(Base):
    __table__ = tables.track_mbid_change
39

40 41
    track_mbid = relationship('TrackMBID')
    account = relationship('Account')
42 43


44 45
class TrackMBIDSource(Base):
    __table__ = tables.track_mbid_source
46

47 48
    track_mbid = relationship('TrackMBID')
    source = relationship('Source')
49 50


51
class Source(Base):
Lukáš Lalinský's avatar
Lukáš Lalinský committed
52
    __table__ = tables.source
53

54 55
    application = relationship('Application')
    account = relationship('Account')
56 57


58 59 60 61 62 63 64 65 66 67 68
class Track(Base):
    __table__ = tables.track


class TrackMeta(Base):
    __table__ = tables.track_meta

    track = relationship('Track')
    meta = relationship('Meta')


Lukáš Lalinský's avatar
Lukáš Lalinský committed
69 70 71 72 73
class Fingerprint(Base):
    __table__ = tables.fingerprint
    track = relationship('Track')


74 75
class Meta(Base):
    __table__ = tables.meta
Lukáš Lalinský's avatar
Lukáš Lalinský committed
76 77 78 79 80 81


class StatsLookups(Base):
    __table__ = tables.stats_lookups

    application = relationship('Application')
Lukáš Lalinský's avatar
Lukáš Lalinský committed
82 83 84 85 86 87 88 89


class Submission(Base):
    __table__ = tables.submission


class SubmissionResult(Base):
    __table__ = tables.submission_result