Guest User

Untitled

a guest
May 2nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. conn_p = p.connect("dbname='p_test' user='postgres' password='postgres' host='localhost'")
  2. conn_t = p.connect("dbname='t_mig1' user='postgres' password='postgres' host='localhost'")
  3.  
  4. cur_p = conn_p.cursor()
  5. cur_t = conn_t.cursor()
  6.  
  7. cur_t.execute("SELECT CAST(REGEXP_REPLACE(studentnumber, ' ', '') as integer), firstname, middlename, lastname FROM sprofile")
  8. rows = cur_t.fetchall()
  9.  
  10. for row in rows:
  11. print "Inserting ", row[0], row[1], row[2], row[3]
  12. 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]))
  13.  
  14. cur_p.commit()
  15. cur_pl.close()
  16. cur_t.close()
Add Comment
Please, Sign In to add comment