Updating the SQLAlchemyPipeline to use properly TvShowDB and LinkDB
This commit is contained in:
parent
d8d8109cdc
commit
1d0cb8ed5d
11
scrarls.py
11
scrarls.py
@ -117,10 +117,19 @@ class SQLAlchemyPipeline:
|
|||||||
show = session.scalars(stmt).first()
|
show = session.scalars(stmt).first()
|
||||||
print(f"{show=}")
|
print(f"{show=}")
|
||||||
if not 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)
|
session.add(show)
|
||||||
else:
|
else:
|
||||||
for key, value in item.items():
|
for key, value in item.items():
|
||||||
|
if key != "download_url":
|
||||||
setattr(show, key, value)
|
setattr(show, key, value)
|
||||||
session.commit()
|
session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user