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:
parent
97a7eef014
commit
abe6b4a83c
1 changed files with 29 additions and 0 deletions
29
royalnet/database/tables/bios.py
Normal file
29
royalnet/database/tables/bios.py
Normal 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
|
Loading…
Reference in a new issue