I cannot write date into Postgres column with type 'date'.
I use this code:
import datetime
import pytz
now = datetime.datetime.now(pytz.timezone("Europe/Moscow"))
sql = "INSERT INTO questions (date) VALUES (%s, %s)" \
% (datetime.date(now.year, now.month, now.day))
cursor.execute(sql)
Also, I tried this:
sql = "INSERT INTO questions (date) VALUES (%s, %s)" \
% (datetime.datetime.now())
cursor.execute(sql)
But I have the same error:
psycopg2.errors.DatatypeMismatch: ╬╪╚┴╩└: ёЄюысхЎ "date" шьххЄ Єшя date, р т√Ёрцхэшх - integer
LINE 1: INSERT INTO questions (id, date) VALUES (10, 2020-12-04)
^
HINT: ╧хЁхяш°шЄх т√Ёрцхэшх шыш яЁхюсЁрчєщЄх хую Єшя.
Can you help me, what's the problem?
2020-12-04is an arithmetic expression.