Я получаю следующую ошибку при хранении данных в sqlite3
File "/Users/qasimbutt/PycharmProjects/IntegratedProject/spider_backend/spider_backend/pipelines.py", line 50, in process_item
self.cursor.execute("insert into raw_tbl values(?,?,?) ",
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.
Мне удалось хранить данные в mongodb очень легко и просто. Но когда я перешел на sqlite3, это дает мне ошибку. Я пытался играть, но не работает легко.
Я пытаюсь получить данные, подобные приведенным ниже, которые, я сомневаюсь, можно сохранить в sqlite3
ERROR: Error processing {'desc': (('View the profiles of professionals named "Royce" on ',),),
'title': (('10,800+ "Royce" profiles | LinkedIn',),),
'url': ('nz.linkedin.com › pub › dir › Royce › '
'nz-9194-Auckland,-New-Zealand',)}
Traceback (most recent call last):
Ниже приведен мой конвейер.
import sqlite3
class SpiderBackendPipeline(object):
# def process_item(self, item, spider):
# return item
#def process_item(self, item, spider):
# self.collection.insert(dict(item))
# print ("Pipeline",+ item['title'][0])
# return item
#Adding new sqlite3 connection
def __init__(self):
self.db_connection()
self.create_tbl()
pass
def db_connection(self):
self.connection = sqlite3.connect("rawdata.db")
self.cursor = self.connection.cursor()
print("DB STATUS:DB Connection established")
def create_tbl(self):
self.cursor.execute("""
drop table if exists raw_tbl
""")
self.cursor.execute("""create table raw_tbl (
title TEXT,
desc TEXT,
url TEXT
)""")
print("DB STATUS:Table created")
def process_item(self, item, spider):
# self.storedb(item)
# return item
#print("Pipeline" +item['title'][0])
#print("DB STATUS: Successfully processed data")
self.cursor.execute("insert into raw_tbl values(?,?,?) ",
(item['title'][0],
item['desc'][0],
item['url'][0],
)
)
print("DB STATUS:Data stored in db")
self.connection.commit()
return item
# def storedb(self):
# self.cursor.execute("""insert into raw_tbl values(?,?,?) """,
# (item['title'][0],
# item['desc'][0],
# item['url'][0],
# )
# )
# print("DB STATUS:Data stored in db")
# self.connection.commit()
#self.connection.close()
# print("DB STATUS:Closing db connection")
def closedb(self):
self.connection.close()
Ценю, не могли бы вы помочь мне здесь и помочь мне понять, что я здесь не так? большое спасибо