Updating the SQLAlchemyPipeline to use properly TvShowDB and LinkDB
This commit is contained in:
parent
d8d8109cdc
commit
1d0cb8ed5d
13
scrarls.py
13
scrarls.py
@ -117,11 +117,20 @@ class SQLAlchemyPipeline:
|
||||
show = session.scalars(stmt).first()
|
||||
print(f"{show=}")
|
||||
if not show:
|
||||
show = TvShowDB(**item)
|
||||
show = TvShowDB(
|
||||
post_id=item["post_id"],
|
||||
post_title=item["post_title"],
|
||||
title=item["title"],
|
||||
date=item["date"],
|
||||
summary=item["summary"],
|
||||
image_url=item["image_url"],
|
||||
links=[LinkDB(link=url) for url in item["download_url"]]
|
||||
)
|
||||
session.add(show)
|
||||
else:
|
||||
for key, value in item.items():
|
||||
setattr(show, key, value)
|
||||
if key != "download_url":
|
||||
setattr(show, key, value)
|
||||
session.commit()
|
||||
except Exception as e:
|
||||
session.rollback()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user