2024-11-19 23:29:01 +08:00
|
|
|
from sqlalchemy import Column, String, TIMESTAMP, func, BIGINT, LargeBinary, ARRAY
|
2024-11-13 03:23:11 +08:00
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
|
|
class SQLarticle(Base):
|
|
|
|
__tablename__ = 'posts'
|
|
|
|
|
2024-11-14 13:03:00 +08:00
|
|
|
id = Column(BIGINT, primary_key=True)
|
2024-11-13 03:23:11 +08:00
|
|
|
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now())
|
|
|
|
hash = Column(String)
|
2024-11-25 21:51:50 +08:00
|
|
|
content = Column(String)
|
2024-11-13 03:23:11 +08:00
|
|
|
igid = Column(String)
|
|
|
|
mark = Column(String)
|
2024-11-14 13:03:00 +08:00
|
|
|
ip = Column(String)
|
|
|
|
reference = Column(BIGINT)
|
2024-11-13 03:23:11 +08:00
|
|
|
|
|
|
|
def __repr__(self):
|
2024-11-25 21:51:50 +08:00
|
|
|
return f"<article(id={self.id}, hash={self.hash}, content={self.content}, igid={self.igid}, mark={self.mark}, created_at={self.created_at}, ip={self.ip}, reference={self.reference})>"
|
2024-11-13 21:20:21 +08:00
|
|
|
|
|
|
|
class SQLlog(Base):
|
|
|
|
__tablename__ = 'logs'
|
|
|
|
|
2024-11-15 02:12:21 +08:00
|
|
|
id = Column(BIGINT, primary_key=True)
|
2024-11-13 21:20:21 +08:00
|
|
|
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now())
|
|
|
|
message = Column(String)
|
|
|
|
source = Column(String)
|
|
|
|
|
|
|
|
def __repr__(self):
|
2024-11-15 02:12:21 +08:00
|
|
|
return f"<log(id={self.id}, created_at={self.created_at}, message={self.message}, source={self.source})>"
|
|
|
|
|
|
|
|
class SQLfile(Base):
|
|
|
|
__tablename__ = 'files'
|
|
|
|
|
|
|
|
id = Column(BIGINT, primary_key=True)
|
|
|
|
created_at = Column(TIMESTAMP(timezone=True), server_default=func.now())
|
|
|
|
type = Column(String)
|
|
|
|
reference = Column(String)
|
|
|
|
binary = Column(LargeBinary)
|
|
|
|
|
|
|
|
def __repr__(self):
|
2024-11-18 02:47:25 +08:00
|
|
|
return f"<file(id={self.id}, created_at={self.created_at}, type={self.type}, binary={self.binary}, reference={self.reference})>"
|
|
|
|
|
|
|
|
class SQLuser(Base):
|
|
|
|
__tablename__ = 'users'
|
|
|
|
|
|
|
|
id = Column(BIGINT, primary_key=True)
|
|
|
|
user = Column(String)
|
|
|
|
password = Column(String) # hash , sha512
|
|
|
|
permission = Column(ARRAY(String))
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return f"<user(id={self.id}, user={self.user}, password={self.password}, permission={self.permission})>"
|