I am trying to upload CSV data to a PostgreSQL database in Python using the COPY FROM STDIN function.
In the CSV file my Date field is DD-MM-YYYY HH:MI and this gives me an error:
psycopg2.errors.DatetimeFieldOverflow: date/time field value out of range: "31-12-2020 08:09"
Is there a way I can define the Date/Time format when using COPY FROM?
DB column is type TIMESTAMP if relevant.
I only know how to do this with a line-by-line INSERT statement.
2020-12-31instead of31-12-2020? You could always import it to a text column and cast it to timestamp afterwards ;-) Would it be an option? Although postgres would cast it withnout any problems:SELECT '31-12-2020 08:09'::timestamp;-)