30 lines
904 B
Python
30 lines
904 B
Python
from sqlalchemy import Column, String, Integer, DateTime, ForeignKey, Text, JSON
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class ScrapeResult(Base):
|
|
"""
|
|
Model for storing scraping results.
|
|
"""
|
|
|
|
__tablename__ = "scrape_results"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
job_id = Column(
|
|
Integer, ForeignKey("scrape_jobs.id", ondelete="CASCADE"), nullable=False
|
|
)
|
|
created_at = Column(DateTime, default=func.now(), nullable=False)
|
|
content_type = Column(String(100), nullable=True)
|
|
headers = Column(JSON, nullable=True)
|
|
html_content = Column(Text, nullable=True)
|
|
extracted_data = Column(JSON, nullable=True)
|
|
|
|
# Relationship
|
|
job = relationship("ScrapeJob", backref="results")
|
|
|
|
def __repr__(self):
|
|
return f"<ScrapeResult(id={self.id}, job_id={self.job_id})>"
|