I am currently working on a task that will migrate a date from PostgreSQL to another PostgreSQL database. One field's data needs to be splitted into three columns (e.g. father_name, needs to split to f_name, f_middle_name, f_last_name) I searched over the net and I think I can use string_to_array for this task. Now my problem is how to assign the array index of string to the fields of the destination DB (destination DB has f_name, f_middle_name, f_last_name while source DB has only father_name field).
cur_t.execute("""
SELECT TRANSLATE(studentnumber, '- ', ''), string_to_array(father_name)
cur_p.execute(""" INSERT INTO "a_recipient" (student_id, f_name, f_middle_name, f_last_name) VALUES ('%s', '%s', '%s', '%s') """ % (row[0]
row[1][0], row[1][1], row[1][2]))
I just don't know how to access the index of the array and assign it as value on the destination fields.
References: string_to_array string_to_array
Any suggestions?