Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- conn_p = p.connect("dbname='p_test' user='postgres' password='postgres' host='localhost'")
- conn_t = p.connect("dbname='t_mig1' user='postgres' password='postgres' host='localhost'")
- cur_p = conn_p.cursor()
- cur_t = conn_t.cursor()
- cur_t.execute("SELECT CAST(REGEXP_REPLACE(studentnumber, ' ', '') as integer), firstname, middlename, lastname FROM sprofile")
- rows = cur_t.fetchall()
- for row in rows:
- print "Inserting ", row[0], row[1], row[2], row[3]
- cur_p.execute(""" INSERT INTO "a_recipient" (id, first_name, middle_name, last_name) VALUES ('%s', '%s', '%s', '%s') """ % (row[0], row[1], row[2], row[3]))
- cur_p.commit()
- cur_pl.close()
- cur_t.close()
Add Comment
Please, Sign In to add comment