ошибка InterfaceError: Error binding parameter 5 - probably unsupported type. в sqlite

Моя функция вытаскивает данные с сайта, и потом мне нужно записать данные в базу. Функция выглядит вот так, сама она работает нормально:

def get_pages_info():
    dict_list = []
    session = requests.session()
    ua = UserAgent(verify_ssl=False)
    for i in list(range(2)):
        req =  session.get(f'https://ovd.news/express-news?page={i}', headers={'User-Agent': ua.random})
        soup = BeautifulSoup(req.text, 'html.parser')
        links = [f"http://ovd.news{el.find('a')['href']}" for el in soup.find_all('div', {'class': 'title'})]
        for id, link in enumerate(links):
            pages_info = dict.fromkeys(['id', 'day', 'month', 'year', 'article', 'right_tag', 'place', 'bottom_tags', 'location', 'error'])
            pages_info['id'] = id
            try:
                req_i = session.get(link, headers={'User-Agent': ua.random})
                soup_i = BeautifulSoup(req_i.text, 'html.parser')

                date = soup_i.find('div', {'class': 'date'})
                a = date.text.split()[0].split('.')
                pages_info['day'] = a[0]
                pages_info['month'] = a[1]
                pages_info['year'] = a[2]

                article = soup_i.find('div', {'class': 'field field-name-body field-type-text-with-summary field-label-hidden'})
                b = article.text.replace('\n', '')
                pages_info['article'] = b.replace('\xa0', ' ')

                right_tag = soup_i.find('div', {'class': 'field-item even'})
                pages_info['right_tag'] = right_tag.text

                place = soup_i.find('div', {'class': 'field-items'})
                pages_info['place'] = place.text.replace('\n', '')

                bottom_tags = soup_i.find('div', {'class': 'field field-name-field-tags-or-subjects field-type-taxonomy-term-reference field-label-inline clearfix'})
                pages_info['bottom_tags'] = bottom_tags.text.replace('Теги:\xa0', '')

                location = soup_i.find('div', {'class': 'field field-name-field-locations field-type-taxonomy-term-reference field-label-inline clearfix'})
                pages_info['location'] = location.text.replace('Локации:\xa0', '')
                
                dict_list.append(pages_info)
                
            except Exception as e:
                pages_info['error'] = e
                dict_list.append(pages_info)
                
        return dict_list

Далее я делаю следующее:

conn = sqlite3.connect('ovd_info.db')
cur = conn.cursor()

cur.executescript("""
create table texts (id int, day int, month int, year int, article text, error text);
create table additional_info (id int, right_tag text, place text, bottom_tags text, location text) 
""")
conn.commit()

ordered_cols = ['id', 'day', 'month', 'year', 'article', 'error']
cur.executemany( """
insert into texts (id, day, month, year, article, error) values (?, ?, ?, ?, ?, ?)
""", [[i[x] for x in ordered_cols] for i in pages_info])
conn.commit()

На что получаю ошибку InterfaceError: Error binding parameter 5 - probably unsupported type. Попробовала сделать так:

for p in pages_info:
    print(type(p['article']))

И у всего по ключу article тип данных - str. Вообще не понимаю. Буду очень благодарна за помощь.


Ответы (0 шт):