Я вставляю данные обхода в postgreSQL. Это мой код scrapy для вставки данных
if spider.name == 'indianexpress':
self.cur.execute("insert into feed_indianexpress(headline,link,date) values(%s,%s,%s)", (item['headline'], item['link'],datetime.now().strftime("%H:%M:%S")))
self.connection.commit()
Но я получаю от Traceback
psycopg2.DataError: invalid input syntax for type timestamp with time zone: "16:40:30"
Это связано с форматом данных. Детская помощь.
Вы вводите в столбец date
неправильный формат даты. Postgresql ожидает yyyy-mm-dd
.
Замените это datetime.now().strftime("%H:%M:%S")
на это date.today().strftime("%Y-%m-%d")