數據插入到Postgres的SQL我想讀一個CSV文件與Python 數據插入到Postgres的SQL,但我有這些錯誤:閱讀CSV到與Python
cursor.execute(passdata)
psycopg2.IntegrityError: duplicate key value violates unique constraint "prk_constraint_project"
DETAIL: Key (project_code)=(%s) already exists.
我的代碼是:
clinicalCSVINSERT = open(clinicalname, 'r')
reader = csv.reader(clinicalCSVINSERT, delimiter='\t')
passdata = "INSERT INTO project (project_code, program_name) VALUES ('%s', '%s')";
cursor.execute(passdata)
conn.commit()`
這個錯誤是什麼意思? 是否有可能有一個工作腳本?
http://stackoverflow.com/questions/1109061/insert-on-duplicate-update-in-postgresql – vks
我的CSV包含這樣的數據: ' file_uuid \t 1B3DB121-B766-486D-AB7D-65AB646CE5AC batch_number \t 304.63.0 project_code \t TCGA disease_code \t ACC day_of_dcc_upload month_of_dcc_upload year_of_dcc_upload (數據是標籤單獨的值) ' –