From abe6b4a83cd64f0e7615e0ddb9a313ad3b5076fe Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 3 Aug 2019 12:42:47 +0200 Subject: [PATCH] Create "bios" table --- royalnet/database/tables/bios.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 royalnet/database/tables/bios.py diff --git a/royalnet/database/tables/bios.py b/royalnet/database/tables/bios.py new file mode 100644 index 00000000..4636b890 --- /dev/null +++ b/royalnet/database/tables/bios.py @@ -0,0 +1,29 @@ +from sqlalchemy import Column, \ + Integer, \ + Text, \ + ForeignKey +from sqlalchemy.orm import relationship +from sqlalchemy.ext.declarative import declared_attr +from .royals import Royal + + +class Bio: + __tablename__ = "bios" + + @declared_attr + def royal_id(self): + return Column(Integer, ForeignKey("royals.uid"), primary_key=True) + + @declared_attr + def royal(self): + return relationship("Royal") + + @declared_attr + def contents(self): + return Column(Text, unique=True, nullable=False) + + def __repr__(self): + return f"" + + def __str__(self): + return self.contents