Answer the question
In order to leave comments, you need to log in
Can't insert object into %s how to do it in python?
self.cursor.execute("insert into %s ( NameTeam, Score, Data) values (%s,%s,%s); ",
psycopg2.errors.SyntaxError: ОШИБКА: ошибка синтаксиса
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
from .spiders import sql
import psycopg2
from .items import MarafonItem
def db(self, item):
b = 0;
a = 0;
table_name = len(item['Category_label'])
total_name = len(item['Names'])
while b <= table_name:
while a <= total_name:
self.cursor.execute("insert into %s ( NameTeam, Score, Data) values (%s,%s,%s); ",
(item['Category_label'][b],
item['Names'][a],
item['Score'][a],
item['Date'][a]
))
self.connect.commit()
a += 1;
b += 1;
Answer the question
In order to leave comments, you need to log in
self.cursor.execute(
"insert into %s ( NameTeam, Score, Data) values (%%s,%%s,%%s); " % item['Category_label'][b],
(item['Names'][a], item['Score'][a], item['Date'][a])
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question