python-gotosocial-notif/models.py

39 lines
839 B
Python
Raw Normal View History

2024-09-29 12:14:20 +02:00
# %%
# ZED Python REPL
2024-10-01 06:32:29 +02:00
from sqlalchemy import Column, Date, Integer, String, create_engine
2024-09-29 12:14:20 +02:00
from sqlalchemy.ext.declarative import declarative_base
2024-10-01 06:32:29 +02:00
from sqlalchemy.orm import sessionmaker
2024-09-29 12:14:20 +02:00
# Engine
2024-10-01 06:32:29 +02:00
engine = create_engine("sqlite:///gotodon.db")
2024-09-29 12:14:20 +02:00
# Base
Base = declarative_base()
2024-10-01 06:32:29 +02:00
2024-09-29 12:14:20 +02:00
# Models
class Notifikasi(Base):
2024-10-01 06:32:29 +02:00
__tablename__ = "notifikasi"
2024-09-29 12:14:20 +02:00
id = Column(Integer, primary_key=True)
inreplyto = Column(String)
post_id = Column(String, unique=True)
created_at = Column(Date)
handler = Column(String)
display_name = Column(String)
type = Column(String)
status = Column(String)
url = Column(String)
remark = Column(String)
def __repr__(self) -> str:
return f"<{self.id} : {self.handler} >"
2024-10-01 06:32:29 +02:00
2024-09-29 12:14:20 +02:00
# Buat tabel
Base.metadata.create_all(engine)
# Session
Session = sessionmaker(bind=engine)