change(fastapi): refactor database ORM model definitions

We don't want to depend on the database to load up data
about the models we define. We now leverage the existing
`aurweb.schema` module for table definitions and set
__table_args__["autoload"] to False.

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-11-07 17:26:05 -08:00
parent e4a5b7fae9
commit 446a082352
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
31 changed files with 212 additions and 356 deletions

View file

@ -1,15 +1,13 @@
from sqlalchemy import Column, Integer
from sqlalchemy.exc import IntegrityError
from aurweb import schema
from aurweb.models.declarative import Base
class License(Base):
__tablename__ = "Licenses"
ID = Column(Integer, primary_key=True)
__mapper_args__ = {"primary_key": [ID]}
__table__ = schema.Licenses
__tablename__ = __table__.name
__mapper_args__ = {"primary_key": [__table__.c.ID]}
def __init__(self, **kwargs):
super().__init__(**kwargs)