1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 03:54:20 +00:00
royalnet/keipack/tables/keipeople.py

23 lines
627 B
Python
Raw Normal View History

2019-11-29 20:18:01 +00:00
from sqlalchemy import *
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
class KeiPerson:
__tablename__ = "keipeople"
2019-11-29 23:45:41 +00:00
@declared_attr
def kpid(self):
return Column(String, primary_key=True)
2019-11-29 20:18:01 +00:00
@declared_attr
def user_id(self):
2019-11-29 23:45:41 +00:00
return Column(Integer, ForeignKey("users.uid"))
2019-11-29 20:18:01 +00:00
@declared_attr
def user(self):
return relationship("User", foreign_keys=self.user_id, backref="kei_people")
2019-11-29 23:45:41 +00:00
def __repr__(self):
return f"<{self.__class__.__qualname__} {self.kpid}{' ' + self.user.username if self.user is not None else ''}>"