0
0 комментариев

Выскакивает ошибка при выполнения запроса на выборку:
_mysql_exceptions.ProgrammingError: not all arguments converted during string formatting
Что я делаю не так?

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 238, in execute
    query = query % args
TypeError: not all arguments converted during string formatting
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "D:/Учеба/Диплом/parsers/smartphone/test10.py", line 309, in <module>
    start_parse_object()
  File "D:/Учеба/Диплом/parsers/smartphone/test10.py", line 177, in start_parse_object
    for _ in executor.map(parse_object, object_urls):
  File "C:\ProgramData\Anaconda3\lib\concurrent\futures\_base.py", line 586, in result_iterator
    yield fs.pop().result()
  File "C:\ProgramData\Anaconda3\lib\concurrent\futures\_base.py", line 432, in result
    return self.__get_result()
  File "C:\ProgramData\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
    raise self._exception
  File "C:\ProgramData\Anaconda3\lib\concurrent\futures\thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "D:/Учеба/Диплом/parsers/smartphone/test10.py", line 128, in parse_object
    row=select_request_db(sql,data)
  File "D:/Учеба/Диплом/parsers/smartphone/test10.py", line 295, in select_request_db
    cursor.executemany(sql,data)
  File "C:\ProgramData\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 283, in executemany
    self.rowcount = sum(self.execute(query, arg) for arg in args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 283, in <genexpr>
    self.rowcount = sum(self.execute(query, arg) for arg in args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\MySQLdb\cursors.py", line 240, in execute
    self.errorhandler(self, ProgrammingError, str(m))
  File "C:\ProgramData\Anaconda3\lib\site-packages\MySQLdb\connections.py", line 52, in defaulterrorhandler
    raise errorclass(errorvalue)
_mysql_exceptions.ProgrammingError: not all arguments converted during string formatting

Код:

def select_request_db(sql, data):
    conn = MySQLdb.connect(host="localhost", user="root", passwd="", db="project")
    conn.set_character_set('utf8')
    cursor = conn.cursor()
    cursor.execute('SET NAMES utf8;')
    cursor.execute('SET CHARACTER SET utf8;')
    cursor.execute('SET character_set_connection=utf8;')
    conn.autocommit(True)
    cursor.executemany(sql,data)
    row = cursor.fetchall()
    conn.close()
 
    text = list(sum(row, ()))
    return text
 
....
sql = """SELECT id FROM locality WHERE name=%s"""
data=[(city_address_shop)]
row=select_request_db(sql,data)

Ошибка выходит только при запросе 1 параметра


Добавить комментарий