Adding a SQLAlchemy model to store scraped posts
This commit is contained in:
parent
f8bb6678f1
commit
177652dce1
18
scrarls.py
18
scrarls.py
@ -9,6 +9,24 @@ from scrapy.crawler import CrawlerProcess
|
|||||||
from scrapy.spiders import CrawlSpider, Rule
|
from scrapy.spiders import CrawlSpider, Rule
|
||||||
from scrapy.linkextractors import LinkExtractor
|
from scrapy.linkextractors import LinkExtractor
|
||||||
|
|
||||||
|
from sqlalchemy import create_engine, Column, Integer, String, Text, DateTime
|
||||||
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
|
class TvShow(Base):
|
||||||
|
__tablename__ = 'tvshows'
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
rlsbb_id = Column(Integer, nullable=False)
|
||||||
|
article_title = Column(String(255), nullable=False)
|
||||||
|
title = Column(String(255), nullable=False)
|
||||||
|
date = Column(DateTime, nullable=False)
|
||||||
|
summary = Column(Text, nullable=True)
|
||||||
|
image_url = Column(String(length=255), nullable=True)
|
||||||
|
download_url = Column(String(length=255), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class TvShowItem(scrapy.Item):
|
class TvShowItem(scrapy.Item):
|
||||||
article_id: scrapy.Field = scrapy.Field()
|
article_id: scrapy.Field = scrapy.Field()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user