Skip to content

Commit 4f2a265

Browse files
committed
Uppercase constant name
1 parent 7f24466 commit 4f2a265

File tree

1 file changed

+3
-3
lines changed
  • web-scraping-with-scrapy-and-mongodb/books/books

1 file changed

+3
-3
lines changed

web-scraping-with-scrapy-and-mongodb/books/books/pipelines.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
class MongoPipeline:
9-
collection_name = "books"
9+
COLLECTION_NAME = "books"
1010

1111
def __init__(self, mongo_uri, mongo_db):
1212
self.mongo_uri = mongo_uri
@@ -28,11 +28,11 @@ def close_spider(self, spider):
2828

2929
def process_item(self, item, spider):
3030
item_id = self.compute_item_id(item)
31-
if self.db[self.collection_name].find_one({"_id": item_id}):
31+
if self.db[self.COLLECTION_NAME].find_one({"_id": item_id}):
3232
raise DropItem(f"Duplicate item found: {item}")
3333
else:
3434
item["_id"] = item_id
35-
self.db[self.collection_name].insert_one(
35+
self.db[self.COLLECTION_NAME].insert_one(
3636
ItemAdapter(item).asdict()
3737
)
3838
return item

0 commit comments

Comments
 (0)