I have a huge file with some data and need to insert it into the crm database.
I have tested it with pandas.to_sql, but I also need to check for duplications and update data in duplications case, so I decided to use this:
SQL_STATEMENT = """
CREATE TEMP TABLE temp
(
LIKE metal
)
ON COMMIT DROP;
COPY temp FROM STDIN WITH
CSV
HEADER
DELIMITER AS ',';
INSERT INTO metal
SELECT *
FROM temp
ON CONFLICT (title) DO UPDATE SET main_category = EXCLUDED.main_category
"""
My issue is, that crm db has autogenerated id's, and I can't it add to my file
So can I just write in the statement to skip the first column (the id's column)?
from copy temp from stdin with skip id
No comments:
Post a Comment