스크래피 파이프 라인 mysql 연결 모듈 오류

바꾸다

파이프 라인을 통해 로컬 데이터베이스로 스크래피를 실행할 수 없습니다. 이미 mysql-connector-python 8.0.19를 설치했으며 동일한 프로젝트 내에서 그러나 Scrapy 파이프 라인 외부에있는 데이터베이스에 데이터를 쓸 수 있습니다. 누군가가 왜 작동하지 않는지 알 수 없습니다.

스크래피 파이프 라인을 통해 데이터를 보내려고하면 다음 오류가 발생합니다.

[twisted] CRITICAL: Unhandled error in Deferred:
File "C:\Users\Viking\PycharmProjects\Indigo_Scrp\IndgoScrp\IndgoScrp\pipelines.py", line 7, in <module>
        from mysql.connector import (connection)
        ModuleNotFoundError: No module named 'mysql

다음은 파이프 라인에 대한 코드입니다.

from mysql.connector import (connection)
from mysql.connector import errorcode

class IndgoscrpPipeline(object):

    def __init__(self):
        self.create_connection()
        self.create_table()

    def create_connection(self):
        self.conn = connection.MySQLConnection(
            host='127.0.0.1',
            user='root',
            passwd='',
            database='Python'
        )
        self.curr = self.conn.cursor()

    def open_spider(self, spider):
        print("spider open")

    def process_item(self, item, spider):
        print("Saving item into db ...")
        self.save(dict(item))
        return item

    def close_spider(self, spider):
        self.mysql_close()
##########################################################################

    def mysql_connect(self):
        try:
            return self.curr.connect(**self.conf)
        except self.curr.Error as err:
            if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
                print("Something is wrong with your user name or password")
            elif err.errno == errorcode.ER_BAD_DB_ERROR:
                print("Database does not exist")
            else:
                print(err)
#########################################


    def create_table(self):
        self.curr.execute(""" DROP TABLE IF EXISTS indigo""")
        self.curr.execute(""" Create table indigo(
        Product_Name text,
        Product_Author text,
        Product_Price text,
        Product_Image text
        )""")

    def process_item(self, item, spider):
        self.store_db(item)


    def store_db(self, item):
        self.curr.execute("""Insert Into indigo values (%s,%s,%s,%s)""",
                          (item['Product_Name'][0],
                           item['Product_Author'][0],
                           item['Product_Price'][0],
                           item['Product_Image'][0],
                           )
                          )
        self.conn.commit()


        return item

        self.conn.close()

*

다음은 내 거미의 코드입니다.

import scrapy


from ..items import IndScrItem
class IndgoSpider(scrapy.Spider):
name = 'Indgo'
start_urls = ['https://www.chapters.indigo.ca/en-ca/books/?link-usage=Header%3A%20books&mc=Book&lu=Main']

def parse(self, response):
    items = IndScrItem()
    Product_Name= response.css('.product-list__product-title-link--grid::text').getall(),
    Product_Author= response.css('.product-list__contributor::text').getall(),
    Product_Price= response.css('.product-list__price--orange::text').getall(),
    Product_Image=  response.css('.product-image--lazy::attr(src)').getall()

    items['Product_Name'] = Product_Name
    items['Product_Author'] = Product_Author
    items['Product_Price'] = Product_Price
    items['Product_Image'] = Product_Image

    yield items

이것은 파이프 라인을 활성화해야하는 설정 파일의 줄입니다.

    ITEM_PIPELINES = {
   'IndgoScrp.pipelines.IndgoscrpPipeline': 100,
}
바꾸다

실제로 내 ide pycharm을 통해 올바른 파이썬을 설치했지만 혼란 스러웠음에도 불구하고 이전에 pip가 잘못된 버전의 mysql-connector를 설치 한 것과 관련이 있다는 사실을 발견했습니다. 둘 다 제거하고 mysql-connector-python을 다시 설치하면 실행할 수 있습니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

스크래피 오류 ImportError : 항목이라는 모듈이 없습니다.

분류에서Dev

Jenkins 파이프 라인 Git 오류 : 원격 저장소에 연결할 때 "호스트 키 확인 실패"

분류에서Dev

플라스크 MySQL LIKE 연결 쿼리의 구문 오류

분류에서Dev

스크래피 파이프 라인 오류로 이름을 가져올 수 없습니다.

분류에서Dev

Python : 이름이 스핑크스 오류 인 모듈 없음

분류에서Dev

다른 스크래피 스파이더 결과를 다른 테이블로 파이프 라인하는 방법

분류에서Dev

모듈 상호 연결 인터페이스 설계

분류에서Dev

Cloud Run이 Cloud SQL 모듈에 연결 오류 Python

분류에서Dev

각 start_url에 대해 mysql을 업데이트하는 스크래피 파이프 라인

분류에서Dev

컴퓨터가 오프라인 일 때 nodeJS를 MySQL에 연결

분류에서Dev

MySQL을 사용하는 Perl 모듈 DBI에서 "오류 2026 기록 : SSL 연결 오류 : 프로토콜 버전 불일치"발생

분류에서Dev

python mysql 데이터베이스 연결 오류

분류에서Dev

XAMPP / MySQL : 데이터베이스 연결 중 오류 발생

분류에서Dev

MYSQL 데이터베이스에 연결 오류 (UWP C #)

분류에서Dev

mysql 데이터베이스에 pentaho 스키마 워크 벤치 연결 오류

분류에서Dev

스크래피를 사용하는 MySQL 데이터베이스 오류

분류에서Dev

Jenkins 파이프 라인 스크립트 오류-MultipleCompilationErrorsException

분류에서Dev

MySQL 연결 오류

분류에서Dev

PHP 스크립트 오류 난 mysql 연결 오류

분류에서Dev

Firebase 이메일 링크 인증은 "오류 발생"- "선택한 페이지 모드가 잘못되었습니다"라는 페이지로 연결됩니다.

분류에서Dev

OMNeT ++의 하위 모듈 연결 오류

분류에서Dev

원격 액세스 MySQL 연결 오류

분류에서Dev

Python이 MySQL에 연결 오류

분류에서Dev

알려진 양호한 온라인 오픈 데이터베이스를 사용한 MySQL Workbench 테스트 연결

분류에서Dev

성공적인 마이그레이션 후에도 라 라벨 데이터베이스 연결 오류

분류에서Dev

인터넷이 연결되면 "모듈 클래스 경로에서 누락되거나 충돌하는 종속성을 확인하십시오"가 사라집니다.

분류에서Dev

프로세스에 PyDev 연결이`ModuleNotFoundError : 'add_code_to_python_process'라는 이름의 모듈이 없습니다.

분류에서Dev

클라우드의 데이터베이스 연결 오류

분류에서Dev

Selenium 드라이버를 기존 Chrome 브라우저 인스턴스에 연결시 오류

Related 관련 기사

  1. 1

    스크래피 오류 ImportError : 항목이라는 모듈이 없습니다.

  2. 2

    Jenkins 파이프 라인 Git 오류 : 원격 저장소에 연결할 때 "호스트 키 확인 실패"

  3. 3

    플라스크 MySQL LIKE 연결 쿼리의 구문 오류

  4. 4

    스크래피 파이프 라인 오류로 이름을 가져올 수 없습니다.

  5. 5

    Python : 이름이 스핑크스 오류 인 모듈 없음

  6. 6

    다른 스크래피 스파이더 결과를 다른 테이블로 파이프 라인하는 방법

  7. 7

    모듈 상호 연결 인터페이스 설계

  8. 8

    Cloud Run이 Cloud SQL 모듈에 연결 오류 Python

  9. 9

    각 start_url에 대해 mysql을 업데이트하는 스크래피 파이프 라인

  10. 10

    컴퓨터가 오프라인 일 때 nodeJS를 MySQL에 연결

  11. 11

    MySQL을 사용하는 Perl 모듈 DBI에서 "오류 2026 기록 : SSL 연결 오류 : 프로토콜 버전 불일치"발생

  12. 12

    python mysql 데이터베이스 연결 오류

  13. 13

    XAMPP / MySQL : 데이터베이스 연결 중 오류 발생

  14. 14

    MYSQL 데이터베이스에 연결 오류 (UWP C #)

  15. 15

    mysql 데이터베이스에 pentaho 스키마 워크 벤치 연결 오류

  16. 16

    스크래피를 사용하는 MySQL 데이터베이스 오류

  17. 17

    Jenkins 파이프 라인 스크립트 오류-MultipleCompilationErrorsException

  18. 18

    MySQL 연결 오류

  19. 19

    PHP 스크립트 오류 난 mysql 연결 오류

  20. 20

    Firebase 이메일 링크 인증은 "오류 발생"- "선택한 페이지 모드가 잘못되었습니다"라는 페이지로 연결됩니다.

  21. 21

    OMNeT ++의 하위 모듈 연결 오류

  22. 22

    원격 액세스 MySQL 연결 오류

  23. 23

    Python이 MySQL에 연결 오류

  24. 24

    알려진 양호한 온라인 오픈 데이터베이스를 사용한 MySQL Workbench 테스트 연결

  25. 25

    성공적인 마이그레이션 후에도 라 라벨 데이터베이스 연결 오류

  26. 26

    인터넷이 연결되면 "모듈 클래스 경로에서 누락되거나 충돌하는 종속성을 확인하십시오"가 사라집니다.

  27. 27

    프로세스에 PyDev 연결이`ModuleNotFoundError : 'add_code_to_python_process'라는 이름의 모듈이 없습니다.

  28. 28

    클라우드의 데이터베이스 연결 오류

  29. 29

    Selenium 드라이버를 기존 Chrome 브라우저 인스턴스에 연결시 오류

뜨겁다태그

보관