1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] IndexError: tuple index out of range - python3.12 and mySQL database

Discussão em 'Python' iniciado por Stack, Setembro 9, 2025.

  1. Stack

    Stack Membro Participativo

    I scrape some data from a website via python and I try to save them to a my-SQL database and I receive an error, can someone help me. The error is


    'price': '£51.77', 'price_no_tax': ('£51.77',), 'price_with_tax': ('£51.77',), 'product_type': ('Books',), 'stars': ('star-rating Three',), 'tax': ('£0.00',), 'title': (None,), 'url': ('https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html',)} Traceback (most recent call last): File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/mysql/connector/cursor.py", line 75, in call return bytes(self.params[index]) ~~~~~~~~~~~^^^^^^^ IndexError: tuple index out of range

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last): File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/scrapy/core/scraper.py", line 387, in start_itemproc output = await maybe_deferred_to_future( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/twisted/internet/defer.py", line 1092, in _runCallbacks current.result = callback( # type: ignore[misc] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/scrapy/utils/defer.py", line 407, in f return deferred_from_coro(coro_f(*coro_args, **coro_kwargs)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Documents/CurrentScrapy/currentscrapy/currentscrapy/pipelines.py", line 90, in process_item self.cur.executemany(""" insert into books ( File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/mysql/connector/cursor.py", line 652, in executemany stmt = self._batch_insert(operation, seq_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/mysql/connector/cursor.py", line 594, in _batch_insert tmp = RE_PY_PARAM.sub(psub, tmp) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Documents/CurrentScrapy/venv/lib/python3.12/site-packages/mysql/connector/cursor.py", line 77, in call raise errors.ProgrammingError( mysql.connector.errors.ProgrammingError: Not enough parameters for the SQL statement 2025-09-09 14:03:02 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://books.toscrape.com/catalogue/libertarianism-for-beginners_982/index.html> (referer: https://books.toscrape.com) 2025-09-09 14:03:02 [scrapy.core.scraper] ERROR: Error processing {'num_reviews': ('0',),
    ​

    Continue reading...

Compartilhe esta Página