1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Create "bios" table

This commit is contained in:
Steffo 2019-08-03 12:42:47 +02:00
parent 97a7eef014
commit abe6b4a83c

View file

@ -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"<Bio of {self.royal}>"
def __str__(self):
return self.contents