-
Notifications
You must be signed in to change notification settings - Fork 11
/
model.py
38 lines (34 loc) · 1.35 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from sqlalchemy import create_engine, Column, Integer, Boolean, TIMESTAMP, Text
from sqlalchemy.orm import sessionmaker, declarative_base,relationship, mapped_column
from sqlalchemy import ForeignKey
import datetime
from config import config
engine = create_engine(config['MARIADB_URI'])
Session = sessionmaker(bind=engine)
Base = declarative_base() # Use declarative_base from sqlalchemy.orm
class Tool(Base):
__tablename__ = 'tools'
id = Column(Integer, primary_key=True)
name = Column(Text)
title = Column(Text)
description = Column(Text)
url = Column(Text)
keywords = Column(Text)
author = Column(Text)
repository = Column(Text)
license = Column(Text)
technology_used = Column(Text)
bugtracker_url = Column(Text)
web_tool = Column(Boolean, default=False)
health_status = Column(Boolean, default=False)
last_checked = Column(TIMESTAMP, default=datetime.datetime.now)
page_num = Column(Integer)
total_pages = Column(Integer)
records = relationship("Record", back_populates="tool")
class Record(Base):
__tablename__ = "records"
id = Column(Integer, primary_key=True)
tool_id = mapped_column(ForeignKey("tools.id"))
tool = relationship("Tool", back_populates="records")
timestamp = Column(TIMESTAMP, default=datetime.datetime.now)
health_status = Column(Boolean, default=False)